Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/SlmGoogleAnalytics/Analytics/CustomVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -116,4 +118,14 @@ public function getScope()
{
return $this->scope;
}

public function setOverride($override)
{
$this->override = $override;
}

public function getOverride()
{
return $this->override;
}
}
14 changes: 9 additions & 5 deletions src/SlmGoogleAnalytics/View/Helper/Script/Analyticsjs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down