Installation with gtag.js, instead of Google Tag Manager
We recommend that you use a tag management system, specifically Google Tag Manager, to implement consent.studio and perhaps other tags.
Log in at https://consent.studio. If you do not yet have an account, you can create one here:
We recommend adding the following script as early after opening the <head>
element of your HTML page as possible and before the initialisation of gtag.js.
This script has placeholders. Make sure that you replace them.
[YOUR DOMAIN HERE]
Also...
wait_for_update
parameter;<script type="text/javascript">
/**
* Manual implementation of the consent.studio CMP
* - Remember to replace the following placeholders: [YOUR DOMAIN HERE]
* - Remember to adjust the default consent signals if needed
*/
/** Initialize the dataLayer variable */
window.dataLayer = window.dataLayer || [];
/** Define a short-hand function for writing to the dataLayer */
function gtag(){dataLayer.push(arguments);}
if(window.location.hash ? window.location.hash == '#cs-scan' : false)
{
/** Don't touch: set all consent signals to granted for the consent.studio cookie scanner */
gtag("consent","default",{ad_storage:"granted",ad_user_data:"granted",ad_personalization:"granted",analytics_storage:"granted",functionality_storage:"granted",personalization_storage:"granted",security_storage:"granted",wait_for_update:500});
}
else
{
/**
* Set the default consent signals
* (You may edit these defaults)
*/
gtag("consent", "default", {
ad_storage: "denied",
ad_user_data: "denied",
ad_personalization: "denied",
analytics_storage: "denied",
functionality_storage: "granted",
personalization_storage: "granted",
security_storage: "granted",
wait_for_update: 500,
});
}
/**
* Set a value for ads data redaction
* - More information: https://support.google.com/analytics/answer/13544947?hl=en
*/
gtag("set", "ads_data_redaction", true);
/** Set the consent.studio developer ID */
gtag("set", "developer_id.dZTlmZj", true);
</script>
<script src="https://consent.studio/[YOUR DOMAIN HERE]/banner.js"></script>
Firstly, it defines the basics: it initialises the dataLayer
variable and provides us with a shorthand function to easily push information to this variable.
Secondly, we set the default consent signals for Google Consent Mode. In our example, all categories (except security_storage
) are instructed to default to denied
. This is the same behaviour that our Google Tag Manager tag template has.
Thirdly, we set the value for ads_data_redaction
. As referred to from the code snippet above, more information about this flag can be found here in the official documentation by Google. Accepted values are true
and false
.
Then, the consent.studio developer ID is set. This is our signature use so that Google can recognise our CMP.
Lastly, we will load the actual banner script into the website.
You can do so in your consent.studio dashboard. More details can be found in this article.
Now that you have finalised your implementation, we recommend keeping an eye on what your consent.studio dashboard (we have a health check page that becomes available to you when issues are detected by our scanner) and the implementation status from within Google services (such as Google Analytics and Google Ads) inform you about.
Please contact consent.studio first, before contacting Google support.
Also, please keep an eye on whether our cookie scanner actually finds cookies on your website. If your website does use cookies, but our scanner does not find any, it may because of any of these causes:
.htpasswd
file.