How can I set up GCM for Google Analytics when it’s not configured within GTM?
The below mentioned method is applicable to all the gtag frameworks.
You can implement the custom script method to set up Google Consent Mode for Google Analytics (GA) without using Google Tag Manager. Here are the steps:
Step 1: Ensure Google Consent Mode v2 is enabled on the CookieYes platform.
Step 2: Copy the custom script and paste it above the GA script and CookieYes script:
<script> window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag("consent", "default", { ad_storage: "denied", ad_user_data: "denied", ad_personalization: "denied", analytics_storage: "denied", functionality_storage: "denied", personalization_storage: "denied", security_storage: "granted", wait_for_update: 2000, }); gtag("set", "ads_data_redaction", true); gtag("set", "url_passthrough", true); </script>
The values in the code are changeable as per your requirements. e.g.
gtag("set", "ads_data_redaction",false);
gtag("set", "url_passthrough",false);
Step 3: Ensure the GA script is placed directly below the Custom Consent Mode Script and above the CookieYes script.
Step 4: Ensure that the order of the scripts is as follows:
- Custom Consent Mode script
- Google Analytics (GA) script (if applicable)
- CookieYes script
Follow our documentation for detailed instructions on Implementing Google Consent Mode. Implement the custom script method to set up Google Consent Mode for GA4 without relying on Google Tag Manager. This approach allows you to comply with data privacy regulations and respect user consent while still being able to use Google Analytics for website tracking.