简体   繁体   English

Adguard阻止GTM的dataLayer.push

[英]Adguard blocks dataLayer.push for GTM

I have function which pushes clicked link attributes to dataLayer for Google tag manager. 我具有将点击的链接属性推送到Google标记管理器的dataLayer的功能。

https://developers.google.com/tag-manager/enhanced-ecommerce https://developers.google.com/tag-manager/enhanced-ecommerce

Problem is that extension "adguard" has ability to block such tracking. 问题在于扩展程序“ adguard”具有阻止此类跟踪的功能。 In adguard it calls 'A filter for all known counters and analytical systems'. 在adguard中,它称为“所有已知计数器和分析系统的过滤器”。 While blocking dataLayer.push, it blocks eventCallback event too and link doesn't get opened. 阻止dataLayer.push时,它也阻止eventCallback事件,并且链接未打开。

Here is function: 这是功能:

 function ga_promoTriggerClick(e) { var p_id = $(e).attr("data-id"); var p_name = $(e).attr("data-name"); var p_creation = $(e).attr("data-creation"); var p_pos = $(e).attr("data-pos"); dataLayer.push({ 'event': 'promotionClick', 'ecommerce': { 'promoClick': { 'promotions': [ { 'id': p_id, 'name': p_name, 'creative': p_creation, 'position': p_pos }] } }, 'eventCallback': function() { var p_href = $(e).attr("href"); if(typeof p_href != "undefined") { document.location = $(e).attr("href"); } } }); } 

How can i send user to link if "adguard" is blocking the dataLayer.push? 如果“ adguard”阻止了dataLayer.push,如何发送用户链接?

Some thoughts: 一些想法:

  • Error / Success / Fail function, but none of them exists. 错误/成功/失败功能,但都不存在。
  • Set timeout 1 second ( this way user will have 'lag' ) 设置超时时间为1秒(这样用户将有'lag')
  • Check if adguard is turned on ( somehow ) and on click check the variable 检查adguard是否已打开(以某种方式),然后单击以检查变量

Thanks for suggestions 感谢您的建议

Solution which worked for me is pretty simple. 对我有用的解决方案非常简单。 All i needed is to check if tag manager works. 我所需要的只是检查标记管理器是否正常工作。

<script type="text/javascript">
window.addEventListener('load', function()
{
    if(window.ga && ga.create) 
    {
        console.log('Google Analytics is loaded');
    } 
    else 
    {
        console.log('Google Analytics is not loaded');    
    }

    if(window.google_tag_manager)
    {
        console.log('Google Tag Manager is loaded');
    }
    else
    {
        console.log('Google Tag Manager is not loaded');
    }
}, false);
</script>

Solution was found here: https://marthijnhoiting.com/detect-if-someone-is-blocking-google-analytics-or-google-tag-manager/ 在这里找到了解决方案: https : //marthijnhoiting.com/detect-if-someone-is-blocking-google-analytics-or-google-tag-manager/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM