简体   繁体   English

Google Analytics(分析)事件+电子商务跟踪=>事件丢失

[英]Google Analytics Event + eCommerce tracking => events lost

I have a site where I am successfully tracking some events, and successfully collecting eCommerce tracking data. 我有一个网站,可以在其中成功跟踪一些事件,并成功收集电子商务跟踪数据。

However, when I try to log an event together with an eCommerce transaction, the event is lost. 但是,当我尝试将事件与电子商务交易记录在一起时,该事件将丢失。

The code is: 代码是:

<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXX-XX', {'userId': 'XXX'});
ga('send', 'pageview');
</script>

... lots of html ... 

<script type="text/javascript">
ga('send', 'event', 'goal', 'purchase', "sub_plan_sku", 10.0, {'nonInteraction': 1});

ga('require', 'ecommerce', 'ecommerce.js');
ga('ecommerce:addTransaction', {'id':'hello_test', 'affiliation': 'example.com', 'revenue': '10.00'});
ga('ecommerce:addItem', {'id':'hello_test', 'name': 'sub_plan_name', 'sku': 'sub_plan_sku', 'category': 'signup', 'price': '10.00', 'quantity': '1'});
ga('ecommerce:send');
</script>

So when I track events by themselves they work, but when I track it like above they don't get registered. 因此,当我自己跟踪事件时,它们会起作用,但是当我像上面那样跟踪事件时,它们不会被注册。

All event-tracking javascript is generated by the same Scala Class, so the precise formatting should be consistent across the two scenarios. 所有事件跟踪javascript都是由相同的Scala类生成的,因此在两种情况下,精确的格式应保持一致。

There are no error messages in the browser console. 浏览器控制台中没有错误消息。

The eCommerce data gets registered correctly. 电子商务数据已正确注册。

??? ???

You need to send the ecommerce event with an existing event. 您需要将ecommerce事件与现有事件一起发送。 See the note under Load the Ecommerce Plugin . 请参阅“ 加载电子商务插件”下的注释。

So in your situation, just move your event after the ecommerce event. 因此,根据您的情况,只需在电子商务事件之后移动事件即可。

<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXX-XX', {'userId': 'XXX'});
ga('send', 'pageview');
</script>

... lots of html ... 

<script type="text/javascript">

ga('require', 'ecommerce', 'ecommerce.js');
ga('ecommerce:addTransaction', {'id':'hello_test', 'affiliation': 'example.com', 'revenue': '10.00'});
ga('ecommerce:addItem', {'id':'hello_test', 'name': 'sub_plan_name', 'sku': 'sub_plan_sku', 'category': 'signup', 'price': '10.00', 'quantity': '1'});
ga('ecommerce:send');

ga('send', 'event', 'goal', 'purchase', "sub_plan_sku", 10.0, {'nonInteraction': 1});
</script>

Looks like there are some bugs in your event tracking method. 您的事件跟踪方法中似乎存在一些错误。

  1. Try to use this event tracking code without "nonInteraction" 尝试使用没有“ nonInteraction”的事件跟踪代码
  2. Try to use only single quotes at all method 尝试在所有方法中仅使用单引号
  3. Try to change values like "10.0" to integer - "10". 尝试将“ 10.0”之类的值更改为整数“ 10”。

    ga('send', 'event', 'goal', 'purchase', 'sub_plan_sku', 10); ga('send','event','goal','purchase','sub_plan_sku',10);

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

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