简体   繁体   English

dataLayer.push function 未推送到 Google Analytics

[英]dataLayer.push function not pushing to Google Analytics

I'm trying to send data to my GA eCommerce instance unsuccessfully and I was wondering if anyone has run into this.我试图将数据发送到我的 GA 电子商务实例失败,我想知道是否有人遇到过这个问题。

Even when I try:即使我尝试:

window.dataLayer = window.dataLayer || [];  

dataLayer.push({
'event': 'mytestingevent',
'eventCallback' : function() {
console.log("working");
}
});

I get the console to log "working" but nothing shows up in my Realtime Analytics.我让控制台记录“工作”,但我的实时分析中没有显示任何内容。

When I preview my GTM changes, the console will log it, and the debugger shows that it fired.当我预览我的 GTM 更改时,控制台将记录它,并且调试器显示它已触发。

All of the other events in my GTM account seem to work fine, but none of them are JS based (they're all css selector based).我的 GTM 帐户中的所有其他事件似乎都运行良好,但它们都不是基于 JS 的(它们都是基于 css 选择器的)。

The end goal is to push product data, for example:最终目标是推送产品数据,例如:

window.dataLayer = window.dataLayer || [];
dataLayer.push({
   'transactionId': "My Test ID",
   'transactionAffiliation': 'My Test Affiliation',
   'transactionTotal': '3',
   'transactionShipping': 'My test shipping',
   'transactionProducts': [{
       'name': "Test Name",
       'sku': 'Ticket',
       'category': "Sample Category",
       'price': "3",
       'quantity': "1"

   }],
    'event' : 'datalayerReady',
    'eventCallback': function() {
      console.log("transaction event was successful");
    }
});

Any help would be greatly appreciated.任何帮助将不胜感激。 Thanks!谢谢!

You have to set event name pushed as event name trigger in GTM and associate this trigger to a Google Analytics tag.您必须在 GTM 中将推送的事件名称设置为事件名称触发器,并将此触发器与 Google Analytics 标记相关联。 So Google Analytics tag will fire when the push is done.因此,当推送完成时,Google Analytics 标签将被触发。

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

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