简体   繁体   中英

E-commerce tracking with google tag manager

I would like to start tracking e-commerce with Google Analytics, to do this I need to pass the values of my data layer into GA using GTM. I have read endless amounts of documentation on the subject and as far as I can tell it should work, however I am still having problems.

My data layer looks something like this on the checkout page of the site

dataLayer = [  
   {  
      'u12':'16149227',
      'ord':'31915976',
      'u3':'XXTX',
      'u7':'190.43',
      'cost':'190.43',
      'revenue':'190.43',
      'name':'XXTX',
      'category':'Annual',
      'id':'31915976'
   }
];

I have set up a trigger in GTM so the following tag only fires on the checkout page of my site.

The tag I have created in GTM is as follows:

    <script>

  ga('require', 'ecommerce', 'ecommerce.js');

  ga('ecommerce:addTransaction', {
    'id' : '{{id}}',
    'revenue': '{{revenue}}'
  });

  ga('ecommerce:addItem', {
    'id' : '{{id}}',
    'sku' : '{{u12}}',
    'name' : '{{name}}',
    'category' : '{{category}}', // Payment Method
    'price' : '{{cost}}', 
    'quantity' : '1'
  }); 

  ga('ecommerce:send');

</script>

Unfortunately this is not working and my Google Analytics is empty in terms of e-commerce transactions, any help on this would be greatly appreciated.

Instead of using a custom HTML tag what you should do is:

  1. Create a Google Analytics Tag.
  2. Select Universal Analytics.
  3. Enter your tracking id Your tracking id can be found here https://support.google.com/analytics/answer/1032385?hl=en
  4. Select Track Type Transaction
  5. Setup the Trigger and save the tag

Hope this helps

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