How to get Google Analytics Enhanced E-Commerce tracking using GA as Tool within DTM?

umang1

15-02-2016

Hello DTM Experts,

We are using Google Analytics as out analytics tool. However, we use DTM as our tag manager due to our core site being under AEM. We want to rollout DTM on our other platforms like Hybris etc. But I am facing a problem. I am not able to track GA Enhanced E-Commerce data using GA as a tool within DTM. There seems to be no documentation or article on the internet.

Has anyone within this community successfully implemented GA EEC tracking using DTM. If yes, can you advise the method?

Thanks and regards,

Vish

Accepted Solutions (1)

Accepted Solutions (1)

ParitMittal

15-02-2016

Hi Umang,

If you are currently using ga.js, you will need to first migrate to analytics.js before using the enhanced ecommerce plug-in. Transaction and item data previously collected using the ecommerce.js plug-in will not be affected by the migration and will remain available in the properties and profiles to which they were originally sent. Please see the following link for more information regarding the same.  https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce

To include ecommerce or advanced ecommerce library you have to setup the require in the GA tool pageCode. Something like:

ga('dtm_ga_standard.require', 'ec');
To use it you have to create custom third party tag in the correct pageLoad rule in order to setup advanced ecommerce tracking, something like:

ga('dtm_ga_standard.ec:setAction', 'purchase', {
      id: s_orderid,
      affiliation: s_orderid,
      revenue: order_total,
      tax: '0',
      shipping: pageViewData.shipment_cost,
      coupon: ''
    });
ga('dtm_ga_standard.send', 'pageview');
Be sure to prevent in the tool custom page code the standard page view using the commend:

return false
When the ecommerce page load rule is running.

Thanks & Regards

Parit Mittal

Answers (6)

Answers (6)

umang1

21-02-2016

Hi Parit,

  1. I have replaced ga('dtm_ga_standard.require', 'ec') with ga('require', 'ec') in GA Tool setting, but still there is no luck.
  2. What exactly is "dtm_ga_standard" by the way? In your first response, you mentioned to use it but in above response you are asking to remove it. Is it supposed to kept as is or needs to be replaced with anything. For example the tracker name? I have tried replacing it with the tracker name as well but still no luck.
  3. The Google Analytics is not already installed and I haven't checked it in the Tool's General settings. My sole method of calling GA Account is via DTM Tools settings only.
  4. The tracker name is provided by DTM GA Tool and it is set correctly as far as I can understand.
  5. The GA Account ID are set correctly. I can see the pageviews and clicks being fired and recorded in GA Reports. Only Ecommerce data does not get recorded though the events are being fired in the console.

Is it possible to have a session with you to share my screen and see if there is anything wrong I am doing?

antoanetao13973

11-07-2017

Dear umang1,

Were you able to find a solution for this issue? I am facing the same problem and I was wondering if you were able to fix it and if so how.

Thank you!

ParitMittal

18-02-2016

Hi Umang,

"Add Product"  like actions  are measured by using the ec:addProduct command with a productFieldObject to add product details, and the ec:setAction command to specify the action being performed while we measure transaction action like "Purchase"  by using the ec:setAction command and setting the action type to purchase. Transaction level details like total revenue, tax, and shipping are provided in an actionFieldObject.

Also, Please replace the line  ga('dtm_ga_standard.require', 'ec') to  ga('require', 'ec'and then check whether the data has been sent to Google Analytics reports or not . 

If the problem still persists then please check whether the tracker name is set correctly or not in the tool setting of Google Universal Analytics.  If you have specified that Google Analytics is already installed on your site's pages, you **must** use the same name here for proper data collection. The default tracker name for Google Analytics is blank. Generally in the legacy implementations we use the following line to create the tracker object.

ga('create', 'UA-XXXXX-Y', 'auto');  

Also, Please verify whether the the correct Account Id's have been set in the GA tool settings for Production and Staging account.

Thanks & Regards

Parit Mittal

umang1

18-02-2016

HI Parit,

Following is my configuration:

  1. In GA Universal Tool > Under Customize Page Code: 
    ga('dtm_ga_standard.require', 'ec');
  2. In Page Load Rule > Under Javascript/Third Party Tags > Non-Sequential Javascript
    ga('ec:addImpression', { 'id': 'P12345', 'name': 'Warhol T-Shirt', 'category': 'Apparel/T-Shirts', 'brand': 'Adobe', 'variant': 'Black', 'list': 'Search Results', 'position': 1, 'dimension1': 'Member' }); ga('ec:setAction', 'detail'); ga('send', 'pageview');
  3. In Event Based Rules > on a Click on Add to Cart button > Javascript/Third Party Tags > Non-sequential Javascript
    ga('ec:addProduct', { 'id': _satellite.getVar("ECommerce - Product Code"), 'name': 'test name', 'category': 'test category', 'brand': 'ResMed', 'variant': 'test - variant', 'price': 'test price', 'quantity': 'test qty' }); ga('ec:setAction', 'add'); ga('send', 'event', 'UX', 'click', 'add to cart');

On loading of page and click of Add to cart buttons, I can see the events getting fired in console, but I don't see any data being captured in Google Analytics reports.

On a secondary note, in your first example you have referred function ga('dtm_ga_standard.ec:setAction', 'purchase' whereas in your second example you have quoted function ga('ec:addProduct'. What is the difference in these two methods? Which one is correct in context of Google Universal Analytics?

Thanks and regards,

Umang

ParitMittal

16-02-2016

Hi Umang,

Please find below my comments in line to your queries. Please let me know if you have any questions or queries.

  1. We are using Google Universal Analytics in our GA Tool as a tool type. I am assuming this should load analytics.js not ga.js as we simply use DTM tool to specify our GA Account. // Yes this will load analytics.js only so no need to worry about it .
  2. Is "ga('dtm_ga_standard.require', 'ec');" the standard method to call a GA plugin within DTM?  //  To reduce the size of the analytics.js library, enhanced ecommerce tracking is not provided in the default library. Instead it is provided as a plugin module that must be loaded before being used. It is basically a method to load the enhanced ecommerce plugin.
  3. I understand the action on pageLoad rule "ga('dtm_ga_standard.ec:setAction', 'purchase', {", can we also use other actions, for example 'add', 'remove' etc. on click and see it firing with onClick event? // yes you call also set other actions also, Please see the following link on How to set other actions -  https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce 
  4. Do we need to add return false with on click events as well? // Ideally we shouldn't add return false with on click events. Following is the example of "Add" functionality . function addToCart(product) {
      ga('ec:addProduct', {
        'id': product.id,
        'name': product.name,
        'category': product.category,
        'brand': product.brand,
        'variant': product.variant,
        'price': product.price,
        'quantity': product.qty
      });
      ga('ec:setAction', 'add');
      ga('send', 'event', 'UX', 'click', 'add to cart');     // Send data using an event.
    }
  5. What is s_orderid here. I am assuming it is a data element needed to be defined within DTM to capture the order id. If not can you please advise if it is not an standard DTM variable. // yes these are data elements, you can also use some  other techniques to fetch the value for the parameters such as revenue, id etc.

 

Kind regards,

Parit Mittal

 

umang1

16-02-2016

Hi Parit,

Thanks for coming back quickly. Following are the clarification needed with regards to your points above:

  1. We are using Google Universal Analytics in our GA Tool as a tool type. I am assuming this should load analytics.js not ga.js as we simply use DTM tool to specify our GA Account.
  2. Is "ga('dtm_ga_standard.require', 'ec');" the standard method to call a GA plugin within DTM? 
  3. I understand the action on pageLoad rule "ga('dtm_ga_standard.ec:setAction', 'purchase', {", can we also use other actions, for example 'add', 'remove' etc. on click and see it firing with onClick event?
  4. Do we need to add return false with on click events as well?
  5. What is s_orderid here. I am assuming it is a data element needed to be defined within DTM to capture the order id. If not can you please advise if it is not an standard DTM variable.

Thanks again for your help. 

Kind regards,

Umang