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.