Integrating the Google Consent Mode into the Consentmo app

Product Updates

9 mins

Dilyana Simeonova
September 21, 2022
Integrating the Google Consent Mode into the Consentmo app

Google Consent Mode Now Available in Consentmo

With this second blog post about Google Consent Mode, we will give you updated information on how it can help adjust your Google tags based on your users' consent status. At the end of the blog post, we also give an additional tip, proven to be very useful for merchants using Google Ads.

Google Consent Mode Integration

What you need to do is to navigate to your store's theme.liquid file:

1. Go to Online Store > Themes

2. From there to Actions

3. Select Edit code

The Edit code option in Themes settings

4. Find the opening tag of the head HTML element - <head> in the theme.liquid file

The opening tag of the head HTML element - <head> in the theme.liquid file

5. Copy the Google Consent Mode script from here and paste it after the <head> tag

After placing the script in the theme.liquid file, the result should look as bellow:

The correct placement of the script in the theme.liquid file

6. Don't forget to click on the Save button, before exiting

Saving the changes in the theme.liquid file
Google Consent Mode Testing

After completing the steps above, Google Consent Mode should be set up in your store. If you want to test it out, below are some ways to do that. Just don't forget to clear your browser cookies or open your store in incognito mode prior testing, so the Cookie bar is visible.

Step 1. Start off by checking if Google Tag Manager's tags are fired initially before the Cookie Bar is accepted. In order to check if the tags are fired, you can either use Google Tag Manager's preview mode or if you don't have access to Google Tag Manager use the Google Tag Assistant browser extension - downloadable from here.

Step 2. After that, you should make sure that there is a default consent entry in the dataLayer. That default consent entry should have ad_storage and analytics_storage properties set to denied or granted depending on the initial state of your cookie bar. In order to check the default consent, you can simply write dataLayer in your browser's console and look for this entry:


{"consent","default",{"ad_storage":"denied or granted","analytics_storage":"denied or granted"}}

Step 3. After making sure that the dataLayer is properly set, you should check your store cookies since these ones: _ga_gid, and _gat, should not be set before the cookie bar is accepted. 

Note that if any of the cookies are set, then you are likely adding them through an inline script, like analytics.js (which does not support Google Consent Mode). In order to properly check which cookies are set in your store, we recommend using the EditThisCookies browser extension, which you can download from here.

Here is how the EditThisCookies extension looks like on your browser

How the EditThisCookies extension looks like on your browser

Step 4. Lastly, you should give your consent by accepting the Cookie Bar and making sure that the Marketing and Analytics cookie categories are not blocked. After accepting it, you will have to check if the cookies that we mentioned in step 3 (_ga_gid, and _gat) are set in your store and also if the updated consent entry is added to the dataLayer. The updated consent entry should have its ad_storage and analytics_storage properties set to granted as shown in this image:

If the properties of the update consent entry in the dataLayer are set, then the Google Consent Mode should be working properly.

If every step of the testing is successful but you are not getting the data you are expecting, unfortunately, we can't provide any further help in this regard.

Google Consent Mode is essentially an API that we use to pass consent data to Google Tag Manager. How a tag is supposed to respond to this data is beyond our purview. We can, and will be happy to check if you have correctly set things up in regards to our app's sending, and Google Tag Manager's receiving of consent settings. However, we have no insight into what tags do with these settings. We can't comment on how Google Analytics should behave when it receives the Google Consent Mode instructions, or speak on Google's behalf in regards to what data should be logged. This may seem dismissive, but there's nothing we can do on our end to improve the data logging in Google Analytics. Our app's scripts merely respectively set and update the consent state to Google Tag Manager.

What else can the Google Consent Mode code do for you?

If you are a merchant working with Google Ads, you are probably getting multiple recommendation messages for Google Consent Mode. Well, we have some good news for you - by adding the script we are talking about in this blog post, the messages will stop, since Google Consent Mode is technically added to your store that way. You're welcome. 

This is all we have for the updated Google Consent Mode blog post. If you have any specific questions do not hesitate to contact us via chat or email, or simply check our FAQ page.

If you liked this article, spread the word