GTM的Google同意模式 [英] Google Consent Mode from GTM

查看:49
本文介绍了GTM的Google同意模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google同意模式实施Google Analytics(分析).
它可以与这两个脚本一起使用.实际上,它无需设置cookie即可进行跟踪.

 < script>window.dataLayer = window.dataLayer ||[];函数gtag(){dataLayer.push(arguments);}gtag(同意",默认",{ad_storage:拒绝",analytics_storage:拒绝",wait_for_update:500});gtag('set','url_passthrough',true);</script> 

还有

 <脚本异步src ="https://www.googletagmanager.com/gtag/js?id=MYCODE"></script>< script>gtag('js',new Date());gtag('config','MYCODE');</script> 

但是,如果我删除最后一部分并改为通过GTM进行跟踪,则它将无法正常工作.
它仅在我将拒绝"更改为授予"时进行跟踪.

任何人都知道如何通过GTM实施分析和同意模式吗?

解决方案

这是我的建议.

  1. 创建2个变量,这些变量可以读取您的同意cookie的状态.目标是让它们返回Cookie的市场营销和统计值的 granted denied 值.您可以通过查找表或自定义javascript变量来完成此操作,具体取决于您要使用的对象.例如,Cookiebot在中拥有自己的变量您可以将其添加到工作区中的模板库,并且它将根据用户给出的同意级别返回 | preferences | marketing | statistics | 的值.它是通过读取自己的cookie并将其解析为以管道分隔的简单格式来实现的.

  2. 添加了Cookiebot同意状态变量后,继续创建查找表(正则表达式类型)变量.在其中,添加最近创建的Cookiebot同意状态变量作为输入变量.添加一行,并在 marketing 中输入Pattern,然后将 granted 添加为Output值.启用设置默认值"并添加拒绝.查看示例标签设置图片完成后,复制标签并为<具有相同值的code> statistics .

  3. 现在,从内部安装Simo Ahava的Google同意模式标签模板模板库(解释在哪里找到它的gif: https://imgur.com/kPlFuCG )

  4. 将同意命令"下拉值保留为默认"

  5. 现在设置Analytics(分析)(与 analytics_storage 对应)和Ads(与 ad_storage )值添加到我们刚刚创建的相应查找表(正则表达式类型)变量中.查看示例行设置图像

  6. 建议尽快在页面上启用默认的同意标签,因此将代码触发优先级设置为1 https://imgur.com/FAxrgwO

  7. 将所有页面"触发器添加到标签,然后保存.

  8. 现在,我们需要为Google同意模式设置 Update 标签.每当用户单击同意横幅时,这将允许您更新设置.如果您使用Cookiebot,则单击横幅广告将根据给定的同意类型生成事件.

  9. 创建一个自定义事件触发器,填写默认的Cookiebot事件值(cookieconsent_marketing | cookieconsent_statistics)并启用选项 Use regex matching ,然后保存触发器

  10. 最后,复制我们刚刚创建的原始Google同意模式标签.在 Consent Command 下拉列表中,选择 Update .检查是否为广告和分析设置了正确的查找表变量 Google同意模式更新设置图片并为其分配刚刚创建的自定义事件触发器.

  11. 别忘了更新您的所有Google标签.如果您具有使用Cookie同意条件检查的触发器设置,则可以将其删除.例如.如果您具有Google Analytics(分析)的综合浏览量标记,并且该标记的同意"级别为XYZ的所有页面"都有触发器,那么请从触发器中删除同意部分,而只需添加常规的所有页面"即可.对于您可能用于ie的任何自定义事件触发器也是如此.点击跟踪(Google Analytics(分析)中的常规事件).请记住,此解决方案仅适用于Google标签,因此请确保您仍在标签触发器(例如Facebook,LinkedIn,Twitter等)的触发器中应用同意条件.如果不确定,请检查与法律顾问.

  12. 测试和;发布,或问我任何问题.

I am implementing Google Analytics with Google Consent Mode.
It works with these two scripts. It will actually track without setting cookies, as meant to.

<script>
    window.dataLayer = window.dataLayer || [];
    function gtag() { dataLayer.push(arguments); }
    gtag("consent", "default", {
        ad_storage: "denied",
        analytics_storage: "denied",
        wait_for_update: 500
    });
    gtag('set', 'url_passthrough', true);
</script>

And

<script async src="https://www.googletagmanager.com/gtag/js?id=MYCODE"></script>
<script>
    gtag('js', new Date());
    gtag('config', 'MYCODE');
</script>

But if I remove the last section and track through GTM instead, it does not work.
It only tracks if I change 'denied' to 'granted'.

Anyone knows how to implement Analytics and Consent Mode through GTM?

解决方案

Here is my advice.

  1. Create 2 variables that can read the status of your consent cookie. The goal is to have them return a value of granted or denied for the marketing and statistics value of your cookie. You can do this through a lookup table or a custom javascript variable, depends on what you like to work with. For instance, Cookiebot has their own variable in the Template Gallery which you can add to your workspace and it will return a value of |preferences|marketing|statistics| depending on what level of consent is given by a user. It does this by reading their own cookie and parsing it into an easy pipe-separated format.

  2. Once you have added the Cookiebot Consent State variable, go ahead and create a lookup table (regex type) variable. In it, add the recently created Cookiebot Consent State variable as the Input Variable. Add a row and type in marketing for Pattern and add granted as the Output value. Enable Set Default Value and add denied. View example Tag setup image After you are done, copy the tag and make one for statistics with the same values.

  3. Now, Install Simo Ahava's Google Consent Mode tag template from within the Template Gallery (gif explaining where to find it: https://imgur.com/kPlFuCG)

  4. Keep the Consent Command dropdown value on 'Default'

  5. Now set the Analytics (corresponds with analytics_storage) and Ads (corresponds with ad_storage) values to the respective lookup table (type regex) variables we just created. View example row settings image

  6. It is advised to have the default consent tag fire as soon as possible on a page, so set the tag firing priority to 1 https://imgur.com/FAxrgwO

  7. Add an All Pages trigger to the tag and then save it.

  8. Now, we need to setup the Update tag for Google Consent Mode. This will allow you to update the settings whenever a user clicks on a consent banner. If you use Cookiebot, the click on the banner will generate events based on the type of consent given.

  9. Create a Custom Event trigger, fill in the default Cookiebot event values (cookieconsent_marketing|cookieconsent_statistics) and enable the option Use regex matching, then save the trigger.

  10. Finally, copy the original Google Consent Mode tag we just created. In the Consent Command dropdown, select Update. Check that the correct lookup table variables are set for Advertising and Analytics Google Consent Mode Update settings image and assign it the Custom Event trigger you just created.

  11. Don't forget to update all your Google tags. If you have triggers setup that use a conditional check on cookie consent, you can remove these. Eg. If you have a pageview tag for Google Analytics that has a trigger for All Page where Consent level is XYZ, then remove the consent part from the trigger and just add a regular All Pages. Same goes for any custom event triggers you might use for ie. click tracking (generic events in GA). Keep in mind, this solution only works for Google tags, so make sure you still apply consent conditions in the triggers of tags like those for Facebook, LinkedIn, Twitter etc. If you are unsure about anything, check with a legal advisor.

  12. Test & publish, or ask me any questions you might have.

这篇关于GTM的Google同意模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆