From 607c51c4461f6e75e3e1dbcc68e8bbc8e844dd5f Mon Sep 17 00:00:00 2001 From: Bas Kamer Date: Tue, 20 May 2014 14:28:15 +0200 Subject: [PATCH 1/7] Adds support to enable display advertising features --- src/SlmGoogleAnalytics/Analytics/Tracker.php | 11 +++++++++++ .../View/Helper/Script/Analyticsjs.php | 12 ++++++++++++ src/SlmGoogleAnalytics/View/Helper/Script/Gajs.php | 12 +++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/SlmGoogleAnalytics/Analytics/Tracker.php b/src/SlmGoogleAnalytics/Analytics/Tracker.php index d16aa96..674ec6c 100644 --- a/src/SlmGoogleAnalytics/Analytics/Tracker.php +++ b/src/SlmGoogleAnalytics/Analytics/Tracker.php @@ -61,6 +61,7 @@ class Tracker protected $enableTracking = true; protected $enablePageTracking = true; protected $allowLinker = false; + protected $enableDisplayAdvertising = false; protected $domainName; protected $anonymizeIp = false; protected $customVariables = array(); @@ -113,6 +114,16 @@ public function getAllowLinker() return $this->allowLinker; } + public function setEnableDisplayAdvertising($enableDisplayAdvertising) + { + $this->enableDisplayAdvertising = $enableDisplayAdvertising; + } + + public function getEnableDisplayAdvertising() + { + return $this->enableDisplayAdvertising; + } + public function setDomainName($domain_name) { $this->domainName = (string) $domain_name; diff --git a/src/SlmGoogleAnalytics/View/Helper/Script/Analyticsjs.php b/src/SlmGoogleAnalytics/View/Helper/Script/Analyticsjs.php index 5feb086..2116f89 100644 --- a/src/SlmGoogleAnalytics/View/Helper/Script/Analyticsjs.php +++ b/src/SlmGoogleAnalytics/View/Helper/Script/Analyticsjs.php @@ -78,6 +78,7 @@ public function getCode() $script .= $this->prepareCreate(); $script .= $this->prepareLinker(); + $script .= $this->prepareDisplayAdvertising(); $script .= $this->prepareTrackEvents(); $script .= $this->prepareTransactions(); $script .= $this->prepareSend(); @@ -206,6 +207,17 @@ protected function prepareLinker() return $output; } + protected function prepareDisplayAdvertising() + { + $output = ''; + + if ($this->tracker->getEnableDisplayAdvertising()) { + $output .= $this->requirePlugin('displayfeatures'); + } + + return $output; + } + protected function prepareTrackEvents() { $events = $this->tracker->getEvents(); diff --git a/src/SlmGoogleAnalytics/View/Helper/Script/Gajs.php b/src/SlmGoogleAnalytics/View/Helper/Script/Gajs.php index 85c3a52..2bd3b85 100644 --- a/src/SlmGoogleAnalytics/View/Helper/Script/Gajs.php +++ b/src/SlmGoogleAnalytics/View/Helper/Script/Gajs.php @@ -82,13 +82,23 @@ public function getCode() protected function getLoadScript() { - return <<