Google跟踪代码管理器未监听dataLayer.push

时间:2019-04-09 05:50:19

标签: angularjs google-analytics google-tag-manager google-datalayer

因此,我们正在努力为客户实施增强型电子商务跟踪。我们通过dataLayer推送完成了此操作。 Web开发人员已按照建议的方式实现了我们的代码,但在某些情况下,有时会丢失dataLayer.push。

我已在“订购成功”页面上附加了以下代码的当前实现方式。

网站上实现的AngularJS可能存在一些问题,如果有人可以帮助我了解如何为那些错过的页面浏览量和dataLayer.push代码实现GTM代码,将不胜感激。

当我在GTM调试窗口中查看时,发生了两个实例;

  1. 购买事件将在dataLayer.push中触发,我们将从Google Analytics(分析)中获取交易数据。
  2. 页面视图将触发,并且不会跟随dataLayer.push事件。即使我检查页面源代码,也可以购买dataLayer.push代码。

        函数getCartproducts(){
        var dataLayerIndex = new Array();
            dataLayerIndex.push({"name": "xxxxxx" , "id" :  "xxxxxx" , "price" :  "11.00" , "category" :  "xxxxx" , "quantity" : 2});
    
        return (JSON.stringify(dataLayerIndex));
    }
    
    function getCoupon(){
        var couponLayerIndex = new Array();
            couponLayerIndex.push('');
    
        return (JSON.stringify(couponLayerIndex[0]));
    }
    
    
    
    window.dataLayer.push({
        'event': 'checkout',
        'ecommerce': {
            'checkout': {
                'actionField': { 'step': 5 },
                'products':
                  JSON.parse(getCartproducts())
            }
        },
    })
    
    
    
    window.dataLayer.push({
        'event': 'purchase',
        'ecommerce': {
            'purchase': {
                'actionField': {
                    'id': '269459',
                    'revenue': 25.65,
                    'tax': '3.85',
                    'shipping':'7.50',
                    'coupon': getCoupon(),
            },
                'products': JSON.parse(getCartproducts())
    }
    }
    });
    

我希望每次用户查看最终的“谢谢”页面时,该代码都会触发自定义购买事件。但是如上所述,我们错过了很多交易。

0 个答案:

没有答案
相关问题