Collecting consents using Tag Manager
Set up seamless cookie tracking with Easycookie and Google Tag Manager, ensuring compliance with Google Consent Mode v2.
Here’s how to set up proper cookie tracking using Easycookie and Google Tag Manager.
Important! If possible, add the Easycookie script to your site first, then configure settings and rules in Google Tag Manager. Otherwise, the configuration will be more challenging and require additional steps.
Rule configuration
Before Google Consent Mode v2, the rule triggering cookie tracking on the site was page initialization. Now, proper configuration requires suspending any tracking and GA tag initialization, until user consent is given. To do this, we are going to create new triggers and add them to the main Google tag.
- Log in to Google Tag Manager.
- Go to the Triggers section.
- Click New to add a new trigger.
- Add a DOM Ready trigger—select DOM Ready as the trigger type and toggle the option to fire trigger on All DOM Ready Events.
- Add a ContentUpdate trigger—select Custom Event as the trigger type, enter the name ConsentUpdate, and toggle the option to fire the trigger on All Custom Events.
- Go to the Tags section and find the main Google tag. Remove initialization trigger firing on all pages.
- Replace it by adding the two triggers you just created—DOM Ready and ConsentUpdate.
- Go to the Advanced Settings in the tag configuration.
- In the Consent Settings section, check Require additional consent for tag to fire
- Click +Add required consent and set it to analytics_storage.
If you don’t see the Consent Settings section, go to Admin -> Container Settings and in the Additional Settings section, toggle on the option Enable consent overview.
This configuration ensures that the GA4-triggering tag loads only when there’s information on the consents given by the user. Simultaneously, the Easycookie script loads the tag on the first page the user visits, making it possible to correctly determine the source from which the user entered the site while adhering to Google Consent Mode v2 rules.
Assigning consents to events
If you have additional tags in your GTM sending events to GA4, you need to assign the appropriate consents to each element. You can do this individually or collectively.
Single tag configuration
- Go to the Tags section.
- Open the tag to which you want to assign consent.
- Go to Advanced Settings -> Consent Settings.
- Check Require additional consent to trigger the tag.
- Click +Add consent requirement and set it to analytics_storage.
- Click Save.
Bulk configuration
- Go to Consent Settings Overview (you can do this by clicking the shield icon next to the New button).
- Select the elements to which you want to assign consent.
- Click the shield icon in the upper right corner to go to the Edit Tag Consent view.
- Check Require additional consent to trigger the tag.
- Click +Add consent requirement and set it to analytics_storage.
- Click Save.
Important! For elements related to ads, sending information to Google Ads or Meta, you also need to add additional consent of type ad_storage. If you use personalization features, also add consent of type personalization_storage. More information about configuring individual consents can be found in Google’s documentation.