// Step 2: This snippet sets a default consent state, instructing Google's technologies how to behave if no consent is present.
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('consent', 'default', {
'analytics_storage': 'denied',
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'region': ["AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR",
"DE", "GR", "HU", "IS", "IE", "IT", "LV", "LI", "LT", "LU",
"MT", "NL", "NO", "PL", "PT", "RO", "SK", "SI", "ES", "SE",
"UK", "CH"
]
});
// Step 3: This snippet sends consent updates from the HubSpot cookie banner to Google's tags using Consent Mode v2
var _hsp = window._hsp = window._hsp || [];
_hsp.push(['addPrivacyConsentListener', function(consent) {
var hasAnalyticsConsent = consent && (consent.allowed || (consent.categories && consent.categories.analytics));
var hasAdsConsent = consent && (consent.allowed || (consent.categories && consent.categories.advertisement));
gtag('consent', 'update', {
'ad_storage': hasAdsConsent ? 'granted' : 'denied',
'analytics_storage': hasAnalyticsConsent ? 'granted' : 'denied',
'ad_user_data': hasAdsConsent ? 'granted' : 'denied',
'ad_personalization': hasAdsConsent ? 'granted' : 'denied'
});
}]);
// Step 4: This snippet installs Google Tag Manager
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXXX');</script>
<!-- End Google Tag Manager -->