The Google tag is a single tag you can add to your website to use Google measurement and advertising products like Google Ads, Google Analytics, Campaign Manager, Display & Video 360, and Search Ads 360. Instead of managing multiple tags for different Google products, you can use the Google tag across your entire site and connect the tag to multiple destinations.
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'TAG_ID');
</script>
You can find your Google tag ID within Google Ads, Google Analytics and Google Tag Manager.
Put the following tag just before UniConsent CMP tag and before your Google tags or any other advertising tags:
<script>
(function() {
if(!window['gtag']) {
window['dataLayer'] = window['dataLayer'] || [];
window['gtag'] = function(){window['dataLayer'].push(arguments);}
}
window['gtag']('set', 'developer_id.dZTcxZD', true);
window['gtag']('consent', 'default', {
ad_storage: 'denied',
functionality_storage: 'denied',
personalization_storage: 'denied',
analytics_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied',
security_storage: 'granted',
wait_for_update: 1000
});
window['gtag']("set", "ads_data_redaction", true);
window['gtag']("set", "url_passthrough", false);
})();
</script>
<!-- // or use gcm short tag
<script src="https://cmp.uniconsent.com/v2/stubgcm.min.js"></script>
-->
<script src="https://cmp.uniconsent.com/v2/stub.min.js"></script>
<script async src='https://cmp.uniconsent.com/v2/YOUR-LICENSE-ID/cmp.js'></script>
<!-- // only load gtag once consent is collected -->
<!-- Google tag (gtag.js) -->
<script type="text/unicscript" unic-purpose-id="3" src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'TAG_ID');
</script>
The above codes delay all the Google tag cookies until the user grants consent.
Put the following tag just before UniConsent CMP tag and before your Google tags (gtag.js) or any other advertising tags:
<script>
(function() {
if(!window['gtag']) {
window['dataLayer'] = window['dataLayer'] || [];
window['gtag'] = function(){window['dataLayer'].push(arguments);}
}
window['gtag']('set', 'developer_id.dZTcxZD', true);
window['gtag']('consent', 'default', {
ad_storage: 'denied',
functionality_storage: 'denied',
personalization_storage: 'denied',
analytics_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied',
security_storage: 'granted',
wait_for_update: 1000
});
window['gtag']("set", "ads_data_redaction", true);
window['gtag']("set", "url_passthrough", false);
})();
</script>
<!-- // or use gcm short tag
<script src="https://cmp.uniconsent.com/v2/stubgcm.min.js"></script>
-->
<script src="https://cmp.uniconsent.com/v2/stub.min.js"></script>
<script async src='https://cmp.uniconsent.com/v2/YOUR-LICENSE-ID/cmp.js'></script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID">
</script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'TAG_ID');
</script>
The above codes communicate with Google services via Consent Mode V2 api. Find more about Google Consent Mode V2
When you encounter issues with missing Consent Mode or TCF (Transparency and Consent Framework) signals on your Google tags, it's essential to start the troubleshooting process with UniConsent support team rather than contacting Google directly.
If you are a Google client, please reach out to us via email at support+google@uniconsent.com or post in the UniConsent Support Community Forum. The UniConsent support team will provide a technical response within 1 business days.
Contact via Phone +441134678278 for urgent issues.
Contact us: support@uniconsent.com or find livechat widget at your dashboard.