Implementing the Usercentrics consent dialog in a Prestashop site:
Add your personal Usercentrics script tag for the consent banner to your Prestashop theme template's header.tpl file inside the <head>
tag,e.g. (highlighted in bold):
data-settings-id
attribute from the default script, you will need to use the following script instead. Without the 'settings-id' fragment, Usercentrics CMP will not display on your site when served through Prestashop.<head>
<script type="text/javascript">
(function(d,s,i,k){var f=d.getElementsByTagName(s)[0],j=d.createElement(s);
j.async=true;j.src='https://app.usercentrics.eu/browser-ui/latest/loader.js'
j.id=i;j.dataset.settingsId=k;f.parentNode.insertBefore(j,f);
})(document,'script','usercentrics-cmp','XXXXXXXXX')
</script>
...
</head>
Whenever you edit a .tpl file you need to force compile in Preferences > Performance before your changes are reflected.
Implementing prior consent on Prestashop plugins, addons and modules:
To enable prior consent (block cookies until user has consented), apply the attribute "data-usercentrics" to all script tags setting cookies. Set value of the attribute to the name of the service that you need consent for. Finally change the script tag attribute "type" from "text/javascript" to "text/plain".
Example on the Google Analytics Module:
Edit the module code directly by going to the module file "ganalytics.php" and edit it.
Make the following addition (bold highlight) to the file under the function "_getGoogleAnalyticsTag":
protected function _getGoogleAnalyticsTag($back_office = false)
{
return '
<script type="text/plain" data-usercentrics="Google Analytics">
(window.gaDevIds=window.gaDevIds||[]).push(\'d6YPbH\');
(function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,\'script\',\'//www.google-analytics.com/analytics.js\',\'ga\');
ga(\'create\', \''.Tools::safeOutput(Configuration::get('GA_ACCOUNT_ID')).'\', \'auto\');
ga(\'require\', \'ec\');
'.($back_office ? 'ga(\'set\', \'nonInteraction\', true);' : '').'
</script>';
}
Comments
0 comments
Please sign in to leave a comment.