From f4e8c78413b4f48ddb9910afa356c3d711188f2b Mon Sep 17 00:00:00 2001 From: horus Date: Tue, 15 Nov 2022 15:52:30 +0100 Subject: integrate external linkshorter including matomo tracking --- app/Http/Controllers/LinkController.php | 38 ++++++++++++++++++++++++++++++++ public/img/whisky_and_book.jpg | Bin 0 -> 109550 bytes public/robots.txt | 1 + resources/views/offers.blade.php | 2 +- routes/web.php | 1 + 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/LinkController.php create mode 100644 public/img/whisky_and_book.jpg diff --git a/app/Http/Controllers/LinkController.php b/app/Http/Controllers/LinkController.php new file mode 100644 index 0000000..4515e04 --- /dev/null +++ b/app/Http/Controllers/LinkController.php @@ -0,0 +1,38 @@ +setTokenAuth( env('MATOMO_LINK_SHORTER_AUTH_TOKEN') ); + #$matomo->setVisitorId( $matomo->getVisitorId() ); + $matomo->setIp( $request->header('X_REAL_IP') ); + $matomo->setUrl( $shortlink ); + $matomo->setUrlReferrer( $request->server('HTTP_REFERER') ); + $matomo->setBrowserLanguage( $request->server('HTTP_ACCEPT_LANGUAGE') ); + $matomo->setUserAgent( $request->server('HTTP_USER_AGENT') ); + + $data = DB::table('all_view')->select('name', 'shop', 'spirit_type', 'long_url')->where('url', "https://l.fuselkoenig.de/" . $shortlink)->limit(1)->get()->first(); + + $matomo->doTrackPageView( $data->name . " - " . $data->shop ); + $matomo->doTrackEvent("Redirect", "Shop", $data->shop); + $matomo->doTrackEvent("Redirect", "Name", $data->name); + $matomo->doTrackEvent("Redirect", "Spirit Type", $data->spirit_type); + $matomo->doTrackEvent("Redirect", "Short URL", $shortlink); + $matomo->doTrackEvent("Redirect", "Long URL", $data->long_url); + + #return response()->json($data); + return redirect()->away($data->long_url, 302); + } +} diff --git a/public/img/whisky_and_book.jpg b/public/img/whisky_and_book.jpg new file mode 100644 index 0000000..26ad110 Binary files /dev/null and b/public/img/whisky_and_book.jpg differ diff --git a/public/robots.txt b/public/robots.txt index 2ab6230..efee8d0 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -13,5 +13,6 @@ Disallow: /stats/ Disallow: /js/ Disallow: /jsp/ Disallow: /jsx/ +Disallow: /s/ Sitemap: https://www.kategorischeraperitif.de/sitemap.xml diff --git a/resources/views/offers.blade.php b/resources/views/offers.blade.php index 479d5dd..859fa3c 100644 --- a/resources/views/offers.blade.php +++ b/resources/views/offers.blade.php @@ -58,7 +58,7 @@