Google Consent Mode
Learn how to pipe consent signals from the Ours Privacy CMP into Google Consent Mode for GTM and GA4.
Google Consent Mode
If you are using the Ours Privacy CDP, consent is already managed server-side and you typically do not need to set up Google Consent Mode separately.
If your setup requires Google Consent Mode, you can use the Ours Privacy CMP JavaScript SDK to listen for consent events and pipe them into Google Consent Mode.
Below is a minimal example:
<!-- Load GTM container as usual -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
// 1. Default: Set denied for analytics/ad storage
gtag('consent', 'default', {
ad_storage: 'denied',
analytics_storage: 'denied',
});
// 2. Normal gtag config
gtag('js', new Date());
gtag('config', 'G-XXXXXXX');
</script>Then, when the user consents via the Ours Privacy CMP, update Google Consent Mode:
// On user acceptance
gtag('consent', 'update', {
ad_storage: 'granted',
analytics_storage: 'granted',
});Next Steps
- CMP JavaScript SDK: Use consent events to trigger Google Consent Mode updates
- Script Blocking: Learn about automatic script blocking
- General Settings: Configure categories and vendors
How is this guide?