summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhorus2022-11-15 15:52:30 +0100
committerhorus2022-11-15 15:52:30 +0100
commitf4e8c78413b4f48ddb9910afa356c3d711188f2b (patch)
tree4e7beab155100383dfe9a7516b932ccf7cf3f801
parent3314af96df7b72bf799fc2e776cbdbd4c4e6dbee (diff)
downloadkategorischeraperitif-f4e8c78413b4f48ddb9910afa356c3d711188f2b.tar.gz
integrate external linkshorter including matomo tracking
-rw-r--r--app/Http/Controllers/LinkController.php38
-rw-r--r--public/img/whisky_and_book.jpgbin0 -> 109550 bytes
-rw-r--r--public/robots.txt1
-rw-r--r--resources/views/offers.blade.php2
-rw-r--r--routes/web.php1
5 files changed, 41 insertions, 1 deletions
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 @@
+<?php
+namespace App\Http\Controllers;
+use Illuminate\Http\Request;
+use App\Helpers\CryptoHelper;
+
+use Illuminate\Support\Facades\DB;
+use App\Http\Controllers\Controller;
+
+class LinkController extends Controller {
+ /**
+ * Shows the index page.
+ *
+ * @return Response
+ */
+ public function redirect(Request $request, $shortlink) {
+
+ $matomo = new \MatomoTracker( env('MATOMO_LINK_SHORTER_ID'), env('MATOMO_URL'));
+ $matomo->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
--- /dev/null
+++ b/public/img/whisky_and_book.jpg
Binary files 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 @@
</div>
<div class="card-footer row">
<div class="col-md-6 col-sm-6">
- <a href="{{ $offer->url }}" class="btn btn-primary">Zum Shop</a>
+ <a href="{{ str_replace('l.fuselkoenig.de', 'www.kategorischeraperitif.de/s', $offer->url) }}" class="btn btn-primary">Zum Shop</a>
</div>
<div class="col-md-6 col-sm-6 price-from">
<p>
diff --git a/routes/web.php b/routes/web.php
index f61e10e..0514648 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -35,3 +35,4 @@ Route::get('/angebote/all/feed', 'FeedController@showPage')->name('all_feed');
Route::get('/angebote/search/feed', 'FeedController@showPage')->name('search_feed');
Route::get('/_/api/lookup', 'LookupController@showPage')->name('lookup');
+Route::get('/s/{shortlink}', 'LinkController@redirect')->name('shortlink')->where('shortlink', '(.+)');