To use anomyzizeIP with this plugin:
includes/templates/YOURTEMPLATE/jscript/jscript_ec_analytics.php
around line 29
change from
toCode:<?php //global $analytics, $cID; $cID = (isset($_SESSION['customer_id'])) ? "customerID#".$_SESSION['customer_id']:"guest"; echo ($cID === "guest") ? "ga('create', '".$trackingID."', 'auto') ;\n":"ga('create', '".$trackingID."', {'userId':'{$cID}'});\n"; echo "ga('require', 'ec');\n"; echo "ga('require', 'displayfeatures');\n"; if (!isset($_SESSION['analytics'])) { echo "ga('send', 'pageview');\n";}
To be GDPR compliant you should also support the GA Opt-Out Cookie:Code:<?php global $analytics, $cID; $cID = (isset($_SESSION['customer_id'])) ? "customerID#".$_SESSION['customer_id']:"guest"; echo ($cID === "guest") ? "ga('create', '".$trackingID."', 'auto') ;\n":"ga('create', '".$trackingID."', {'userId':'{$cID}'});\n"; echo "ga('set', 'anonymizeIp', true); \n"; echo "ga('require', 'ec');\n"; echo "ga('require', 'displayfeatures');\n"; if (!isset($_SESSION['analytics'])) { echo "ga('send', 'pageview');\n";}
Integrate the following link to your privacy policy:
And integrate the following script somewhere in the head section in includes/templates/YOURTEMPLATE/common/html_header.phpCode:<a onclick="alert('Google Analytics has been disabled');"href="javascript:gaOptout()">Disable Google Analytics</a>
(Change UA-1234567 to your own ID)
The user ID is sent to Google Analytics but this does not contain any personal data so I' m not sure what should not be GDPR compliant doing so.Code:<script type="text/javascript"> var gaProperty = 'UA-1234567'; var disableStr = 'ga-disable-' + gaProperty; if (document.cookie.indexOf(disableStr + '=true') > -1) { window[disableStr] = true; } function gaOptout() { document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/'; window[disableStr] = true; } </script>


Reply With Quote
