简体   繁体   中英

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.

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.

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.

<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

2) Verify that those websites dont't have another GA analytics code that overwrite your code. In order to avoid conflicts I recommend you to rename the "ga" global object to "myga" or something like that. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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