diff options
| author | horus | 2018-02-15 17:48:34 +0100 |
|---|---|---|
| committer | horus | 2018-02-15 17:48:34 +0100 |
| commit | b131ce750740ddb9c47515727327c06aa0d22aad (patch) | |
| tree | bdb90d7fe9a00d7b044ec12f459a208b3b7cdf23 | |
| parent | e9d72f489e99abef29340c5bb789ad080500f6c5 (diff) | |
| download | alkobote-b131ce750740ddb9c47515727327c06aa0d22aad.tar.gz | |
Matomo tracks rss usage. (website)
| -rw-r--r-- | site/app/Http/Controllers/FeedController.php | 40 | ||||
| -rw-r--r-- | site/composer.json | 1 | ||||
| -rw-r--r-- | site/composer.lock | 42 |
3 files changed, 79 insertions, 4 deletions
diff --git a/site/app/Http/Controllers/FeedController.php b/site/app/Http/Controllers/FeedController.php index 9ea3621..3cd53b1 100644 --- a/site/app/Http/Controllers/FeedController.php +++ b/site/app/Http/Controllers/FeedController.php @@ -70,12 +70,38 @@ class FeedController extends Controller { */ setlocale(LC_TIME, 'de_DE.utf8'); + if ( "" != env('PIWIK_RSS_ID') ) { + $piwik = new \PiwikTracker( env('PIWIK_RSS_ID'), env('PIWIK_RSS_URL') ); + $piwik->setTokenAuth( env('PIWIK_RSS_AUTH_TOKEN') ); + $piwik->setVisitorId( $piwik->getVisitorId() ); + $piwik->setIp( $request->header('X_REAL_IP') ); + $piwik->setUrl( $request->fullUrl() ); + + $piwik->setUrlReferrer( $request->server('HTTP_REFERER') ); + $piwik->setBrowserLanguage( $request->server('HTTP_ACCEPT_LANGUAGE') ); + $piwik->setUserAgent( $request->server('HTTP_USER_AGENT') ); + + $piwik->doTrackPageView( ucfirst($view_name) . "-Feed" ); + + if ( "" != Input::get('sort') ) { + $piwik->doTrackEvent("sort", Input::get('sort') ); + } + if ( "" != Input::get('order') ) { + $piwik->doTrackEvent("order", Input::get('order') ); + } + if ( "" != Input::get('q') ) { + $piwik->doTrackEvent("search_phrase", Input::get('q') ); + } + } + + + $feed = \App::make("feed"); $feed->title = "Sonderangebote"; - $feed->description = 'Finde immer die günstigsten Angebote im Bereich Spirituosen. Täglich neue Schnäppchen.'; - $feed->logo = '/img/paw-400-400.png'; - $feed->link = url('feed'); + $feed->description = 'Finde immer die günstigsten Angebote im Bereich Spirituosen. Regelmäßig neue Schnäppchen.'; + $feed->logo = url('/img/paw-400-400.png'); + $feed->link = url( $request->fullUrl() ); $feed->setDateFormat('timestamp'); // 'datetime', 'timestamp' or 'carbon' $feed->pubdate = $data[0]->created_at; $feed->lang = 'de'; @@ -83,6 +109,14 @@ class FeedController extends Controller { $feed->setTextLimit(5000); // maximum length of description text foreach ( $data as $offer ) { + + # Adds campagin + $offer->url = $offer->url . "?pk_campaign=feed&pk_kwd=" . urlencode($offer->name) . "&pk_source=" . $view_name . "_feed"; + + if ( "" != env('PIWIK_RSS_ID') ) { + $piwik->doTrackContentImpression($offer->spirit_type, $offer->name, $offer->long_url); + } + $desc = '<p><img src="'.$offer->image_url.'"></p><p><strong>'.$offer->spirit_type.'</strong><br>Statt ' . \TF::fF($offer->original_price) . '€ nur noch ' . \TF::fF($offer->discounted_price) . "€ (".$offer->procent."% Rabatt)."; $feed->add($offer->name, $offer->shop, $offer->url, $offer->created_at, $desc, $desc); } diff --git a/site/composer.json b/site/composer.json index 39587c4..44e1e2c 100644 --- a/site/composer.json +++ b/site/composer.json @@ -9,6 +9,7 @@ "fideloper/proxy": "~4.0", "laravel/framework": "5.6.*", "laravel/tinker": "~1.0", + "piwik/piwik-php-tracker": "^1.4", "roumen/feed": "^2.12" }, "require-dev": { diff --git a/site/composer.lock b/site/composer.lock index c48b766..f1064d7 100644 --- a/site/composer.lock +++ b/site/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "1ff6dde5a4092d06ccfcce8fc2b7d989", + "content-hash": "9e4429f37916161d55b6c32191b012fc", "packages": [ { "name": "dnoegel/php-xdg-base-dir", @@ -968,6 +968,46 @@ "time": "2017-09-27T21:40:39+00:00" }, { + "name": "piwik/piwik-php-tracker", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/piwik/piwik-php-tracker.git", + "reference": "f9a0168c87f01f2d5de95029a1ba0d1fd6c3d5ab" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/piwik/piwik-php-tracker/zipball/f9a0168c87f01f2d5de95029a1ba0d1fd6c3d5ab", + "reference": "f9a0168c87f01f2d5de95029a1ba0d1fd6c3d5ab", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "." + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "The Piwik Team", + "email": "hello@piwik.org", + "homepage": "http://piwik.org/the-piwik-team/" + } + ], + "description": "PHP Client for Piwik Analytics Tracking API", + "homepage": "http://piwik.org", + "keywords": [ + "analytics", + "piwik", + "tracker" + ], + "time": "2017-11-09T03:20:23+00:00" + }, + { "name": "psr/container", "version": "1.0.0", "source": { |
