You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Hostinger AI Builder中通过GTM集成CookieBot后Google Consent Mode扫描异常问题求助

大家好,我最近在折腾CookieBot和Google Consent Mode的集成,卡了好几天实在没辙,来请教下各位:

  • 我先是严格按照官方指南在Google Tag Manager里部署了CookieBot,但不管怎么调整配置,Google Consent Mode扫描工具始终显示「Cookiebot to GCM signalling is NOT active」。
  • 我的网站是用Hostinger AI Builder搭建的,一开始是通过平台的集成功能直接添加GTM ID,结果扫描工具直接抛出错误。
  • 后来我试着参考ChatGPT给出的方案,在页面<head>里手动注入了一段自定义代码(代码如下),之后又把代码里的consent事件监听器部分删掉了。现在扫描时其他检查项都显示正常(绿色通过),但最开始的那个「Cookiebot to GCM signalling is NOT active」提示还是存在,完全摸不着头脑到底哪里出问题了。
<head>
  <!-- Default consent state -->
  <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('consent', 'default', {
      'ad_storage': 'denied',
      'analytics_storage': 'denied',
      'functionality_storage': 'denied',
      'personalization_storage': 'denied',
      'security_storage': 'granted'
    });
  </script>
  <!-- Cookiebot script -->
  <script id="Cookiebot" src="https://consent.cookiebot.com/uc.js" data-cbid="YOUR-COOKIEBOT-ID" type="text/javascript" async></script>
  <!-- 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-PSPKPW5F');
  </script>
  <!-- 我后来移除了这部分Consent event listeners代码 -->
  <!-- <script>
    window.addEventListener('CookiebotOnAccept', function() {
      dataLayer.push({
        'event': 'consent_update',
        'ad_storage': 'granted',
        'analytics_storage': 'granted',
        'functionality_storage': 'granted',
        'personalization_storage': 'granted',
        'security_storage': 'granted'
      });
      gtag('consent', 'update', {
        'ad_storage': 'granted',
        'analytics_storage': 'granted',
        'functionality_storage': 'granted',
        'personalization_storage': 'granted',
        'security_storage': 'granted'
      });
    });
    window.addEventListener('CookiebotOnDecline', function() {
      dataLayer.push({
        'event': 'consent_update',
        'ad_storage': 'denied',
        'analytics_storage': 'denied',
        'functionality_storage': 'denied',
        'personalization_storage': 'denied',
        'security_storage': 'granted'
      });
      gtag('consent', 'update', {
        'ad_storage': 'denied',
        'analytics_storage': 'denied',
        'functionality_storage': 'denied',
        'personalization_storage': 'denied',
        'security_storage': 'granted'
      });
    });
  </script> -->
</head>

有没有大佬遇到过类似的问题?或者能帮我排查下可能的原因?

内容来源于stack exchange

火山引擎 最新活动