Skip to content

Commit b1fb0dc

Browse files
use set command to set anonymizeIp field to true on the tracker
1 parent ed86a75 commit b1fb0dc

File tree

1 file changed

+3
-8
lines changed
  • app/code/Magento/GoogleAnalytics/Block

1 file changed

+3
-8
lines changed

app/code/Magento/GoogleAnalytics/Block/Ga.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ public function getPageTrackingCode($accountId)
8282

8383
$anonymizeIp = "";
8484
if ($this->_googleAnalyticsData->isAnonymizedIpActive()) {
85-
$anonymizeIp = ", {'anonymizeIp': true}";
85+
$anonymizeIp = "\nga('set', 'anonymizeIp', true);";
8686
}
8787

8888
return "\nga('create', '" . $this->escapeHtmlAttr($accountId, false)
89-
. ", 'auto');\nga('send', 'pageview'{$optPageURL}{$anonymizeIp});\n";
89+
. ", 'auto');{$anonymizeIp}\nga('send', 'pageview'{$optPageURL});\n";
9090
}
9191

9292
/**
@@ -111,11 +111,6 @@ public function getOrdersTrackingCode()
111111

112112
$result[] = "ga('require', 'ec', 'ec.js');";
113113

114-
$anonymizeIp = "";
115-
if ($this->_googleAnalyticsData->isAnonymizedIpActive()) {
116-
$anonymizeIp = ", {'anonymizeIp': true}";
117-
}
118-
119114
foreach ($collection as $order) {
120115
if ($order->getIsVirtual()) {
121116
$address = $order->getBillingAddress();
@@ -153,7 +148,7 @@ public function getOrdersTrackingCode()
153148
$order->getBaseShippingAmount()
154149
);
155150

156-
$result[] = "ga('send', 'pageview'{$anonymizeIp});";
151+
$result[] = "ga('send', 'pageview');";
157152
}
158153
return implode("\n", $result);
159154
}

0 commit comments

Comments
 (0)