简体   繁体   English

Google Analytics(分析)未跟踪增强型电子商务数据

[英]Google analytics not tracking enhanced ecommerce Data

i manage several hotels on analytics, actually have like 400, and we are updating the ecommerce data to enhanced ecommerce. 我管理着数家酒店进行分析,实际上拥有400家,我们正在将电子商务数据更新为增强型电子商务。

when i updated the scripts to e ecommerce on 100 hotels, no one was working, so i ran a test and i found that the isogram analytics code wasnt implemented, fixed that and now 70/100 hotels are getting ecommerce data. 当我将脚本更新为100家酒店的电子商务时,没有人在工作,因此我进行了测试,发现没有实施isogram分析代码,并解决了现在有70/100家酒店正在获取电子商务数据的问题。

idk if is matter of time to get the data on the last 30 hotels but here is the code, if anyone can see anything wrong, thanks. idk如果花时间来获取最近30家酒店的数据,但这是代码,如果有人看到错误,谢谢。

<script>
(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', 'viewcode', 'auto', {'allowLinker': true});
        // Load the plugin.
    ga('require', 'linker');
        // Define which domains to autoLink.
    ga('linker:autoLink',['websites']);
    ga('send', 'pageview');

    ga('require', 'ec');
    ga('set', '&cu', 'MXN'); 

    ga('ec:addProduct', {
      'id': '{SkuCode}', 
      'name': '{ProductName}',
      'category': '{Category}', 
      'price': '{UnitPrice}',
      'quantity': {Quantity}  
    });

    ga('ec:setAction', 'purchase', {
       id: '{NoReservation}',       
       revenue: '{Total}',  
       tax: '{Tax}'       
    });
    ga('send', 'event');     
</script>

The analytics code that you are using it looks right, however in order to assure that analytics code is pushed from the all the hotels websites I recommend you to follow the following steps: 您正在使用的分析代码看起来不错,但是为了确保从所有酒店网站推送分析代码,我建议您遵循以下步骤:

1) Check that hotels domains name are correctly in the "linker" parameter 1)检查“链接器”参数中的酒店域名是否正确

2) Verify that those websites dont't have another GA analytics code that overwrite your code. 2)确认这些网站没有其他GA分析代码会覆盖您的代码。 In order to avoid conflicts I recommend you to rename the "ga" global object to "myga" or something like that. 为了避免冲突,我建议您将“ ga”全局对象重命名为“ myga”或类似的名称。 Example: 例:

<script>
(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','myga');

    myga('create', 'viewcode', 'auto', {'allowLinker': true});
        // Load the plugin.
    myga('require', 'linker');
        // Define which domains to autoLink.
    myga('linker:autoLink',['websites']);
    myga('send', 'pageview');
...

You can check when a hotel is pushing events if you are using the GA Real-time in the GA dashboard. 如果您在GA信息中心中使用GA Real-time,则可以检查酒店何时推送事件。

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

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