diff --git a/src/SlmGoogleAnalytics/Analytics/CustomVariable.php b/src/SlmGoogleAnalytics/Analytics/CustomVariable.php index 4cde50e..adce151 100644 --- a/src/SlmGoogleAnalytics/Analytics/CustomVariable.php +++ b/src/SlmGoogleAnalytics/Analytics/CustomVariable.php @@ -48,13 +48,15 @@ class CustomVariable protected $name; protected $value; protected $scope; + protected $override = false; - public function __construct($index, $name, $value, $scope = self::SCOPE_PAGE_LEVEL) + public function __construct($index, $name, $value, $scope = self::SCOPE_PAGE_LEVEL, $override = false) { $this->setIndex($index); $this->setName($name); $this->setValue($value); $this->setScope($scope); + $this->setOverride($override); } public function setIndex($index) @@ -116,4 +118,14 @@ public function getScope() { return $this->scope; } + + public function setOverride($override) + { + $this->override = $override; + } + + public function getOverride() + { + return $this->override; + } } diff --git a/src/SlmGoogleAnalytics/View/Helper/Script/Analyticsjs.php b/src/SlmGoogleAnalytics/View/Helper/Script/Analyticsjs.php index 5a64b81..fa43215 100644 --- a/src/SlmGoogleAnalytics/View/Helper/Script/Analyticsjs.php +++ b/src/SlmGoogleAnalytics/View/Helper/Script/Analyticsjs.php @@ -174,11 +174,15 @@ protected function prepareSend() if (count($customVariables) > 0) { foreach ($customVariables as $customVariable) { - $index = $customVariable->getIndex(); - $key = 'dimension' . $index; - $value = $customVariable->getValue(); - - $parameters[$key] = $value; + if ($customVariable->getOverride()) { + $parameters[$customVariable->getName()] = $customVariable->getValue(); + } else { + $index = $customVariable->getIndex(); + $key = 'dimension' . $index; + $value = $customVariable->getValue(); + + $parameters[$key] = $value; + } } }