Expand my Community achievements bar.

Help shape the future of AI assistance by participating in this quick card sorting activity. Your input will help create a more effective system that better serves your needs and those of your colleagues.
SOLVED

DTM - Implement Google Analytics Enhanced E-Commerce tracking

Avatar

Level 2

Could you advice in getting the Google Analytics Enhanced E-Commerce tracking implementation via DTM?

The only relevant documentation I found is https://forums.adobe.com/message/9547295#9547295 and there is no confirmation if the method works. 

We have a shopping cart and visitor comes directly to the Cart View with 2 products pre-selected.

There is 3 steps in the transaction - Step 1: Cart page, Step 2: Cart Confirmation page and Step 3: Thank you page​.

Each page has dataLayer with the 2 products information. Product ID (SKU), Quantity, Price per quantity.

product: {

item: [{

  productID: 'SKUID',

  productQuantity: 10,

  productPriceWithoutTax: 30.50},

{

  productID: 'SKUID',

  productQuantity: 10,

  productPriceWithoutTax: 35.45}]

}

What I have done so far, but still in the GA - Ecommerce report there is no data. The GA is firing and if I add console.log outside of the ga function on page load, it triggers but not inside ga function.

1) Under Installed Tool, added GA as new tool with Account IDs for bother Production Account ID and Staging Account ID.

2) In GA tool, under Customize Page Code - Open Editor and paste in ga('require', 'ec');​

3) In Rules > Page Load Rules, for the Step 1: Cart page (condition Trigger rule at Bottom of page), added under Javascript/ Third Party Tags > Non-Sequential , the following code ( in reference to the GA documentation at https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce )

function checkout(cart) {

  for(var i = 0; i < cart.length; i++) {

    var product = cart[i];

    ga('ec:addProduct', {

      'id': dataLayer.product.item.productID,

      'quantity': dataLayer.product.item.productQuantity,

      'price': (dataLayer.product.item.productPriceWithoutTax)*(dataLayer.product.item.productQuantity)

    });

  }

}

ga('ec:setAction','checkout', {

    'step': 1

});

ga('send', 'pageview');

4) In Rules > Page Load Rules, for the Step 2: Cart Confirmation page (condition Trigger rule at Bottom of page), added under Javascript/ Third Party Tags > Non-Sequential , the following code

function checkout(cart) {

  for(var i = 0; i < cart.length; i++) {

    var product = cart[i];

    ga('ec:addProduct', {

      'id': dataLayer.product.item.productID,

      'quantity': dataLayer.product.item.productQuantity,

      'price': (dataLayer.product.item.productPriceWithoutTax)*(dataLayer.product.item.productQuantity)

    });

  }

}

ga('ec:setAction','checkout', {

    'step': 2

});

ga('send', 'pageview');

5) In Rules > Page Load Rules, for the Step 3: Thank you page (condition Trigger rule at Bottom of page), added under Javascript/ Third Party Tags > Non-Sequential , the following code

ga('set', 'currencyCode', dataLayer.transaction.currencyCode);

ga('ec:addProduct', {

  'id': dataLayer.product.item.productID,

  'quantity': dataLayer.product.item.productQuantity,

  'price': (dataLayer.product.item.productPriceWithoutTax)*(dataLayer.product.item.productQuantity)

});

ga('ec:setAction', 'purchase', {

  'id': dataLayer.transaction.transactionID,

  'affiliation': 'Digital River - Online',

  'revenue': dataLayer.transaction.total.transactionTotal,

  'tax': dataLayer.transaction.total.taxRate,

  'coupon': dataLayer.transaction.total.voucherDiscount

});

ga('send', 'pageview');

Thanks in advance. Your support is highly appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 9

Also, check if you are using a custom tracker name. If you implemented UA as a tool in DTM, then by default DTM generates a namespace for your UA tracker.

You can verify by going to your UA tool settings, under the General tab, under Tracker Name.  If the dropdown shows "Specify Name", then take note of the custom value in the field to the right.

If the dropdown says "DTM Generated Name" (the default value), then scroll down to the Customize Page Code section, and under Tracker Name, you should see a value something like this: c4e956daca8f11e79240d310eb27af6f (note: this is an example value and should not be the same as your value!)

If you found a value in either of those places, then your UA tracker has a custom namespace, and you must use it in your code for UA to properly track.

So for example, the ecommerce require you add in your UA Custom Page Code > Open Editor box, should look like this (but with your namespace)

ga('c4e956daca8f11e79240d310eb27af6f.require', 'ec');

return false;

You will need to do the same thing for all of your other ga(..) commands in all of your code, as well, e.g.

View solution in original post

5 Replies

Avatar

Employee

Hi,

If you are able to see the DTM rule firing and the beacon is present that means the configuration is alright and DTM is following them, however, you can still run the following checks:

  • Please ensure to prevent the standard page view using the comment in the tool custom page code: return false;

        When the ecommerce page load rule is running.

  • Also, ensure the option to 'Enable support for Google Universal Analytics Premium features' is checked under the General section within the tool.

if you are still not able to see data in Google, I'd say they are the best ones to seek assistance on this since we don't have much expertise/visibility into how the reporting functionality works.

Avatar

Level 2

Thanks for the reply.

Where do I put this code

return false;

after ga('require', 'ec'); ?

In GA tool, under Customize Page Code -

ga('require', 'ec');

return false;

Avatar

Correct answer by
Level 9

Also, check if you are using a custom tracker name. If you implemented UA as a tool in DTM, then by default DTM generates a namespace for your UA tracker.

You can verify by going to your UA tool settings, under the General tab, under Tracker Name.  If the dropdown shows "Specify Name", then take note of the custom value in the field to the right.

If the dropdown says "DTM Generated Name" (the default value), then scroll down to the Customize Page Code section, and under Tracker Name, you should see a value something like this: c4e956daca8f11e79240d310eb27af6f (note: this is an example value and should not be the same as your value!)

If you found a value in either of those places, then your UA tracker has a custom namespace, and you must use it in your code for UA to properly track.

So for example, the ecommerce require you add in your UA Custom Page Code > Open Editor box, should look like this (but with your namespace)

ga('c4e956daca8f11e79240d310eb27af6f.require', 'ec');

return false;

You will need to do the same thing for all of your other ga(..) commands in all of your code, as well, e.g.

Avatar

Level 1

Hi, are you able to make it work in the end?