AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
2.6K members online now
2.6K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Ecommerce Data / DataLayer Not Pushing to Analytics

SMG Badged Google Partner
Badged Google Partner
# 1
SMG Badged Google Partner
Badged Google Partner

We are using Google Tag Manager. Transaction data is in the datalayer on the order confirmation page as follows:

 

image001.jpg

In console I wrote “universal_variable” which I believe holds all the datalayer data. I wrote a custom JS function (below) which uses Google's required variables and fires when I place a sample order. However the transaction information is not registering in GA. What are we missing? Help is much appreciated. Thanks. 

 

 

<script>
  var obj_to_push = {
	"transactionId": universal_variable.transaction.order_id,
	"transactionShipping":universal_variable.transaction.shipping_cost,
	"transactionTax": universal_variable.transaction.tax,
	"transactionTotal":universal_variable.transaction.total,
	"transactionProducts": []
}
if(universal_variable){
	universal_variable.transaction.line_items.forEach(function(item) {
		console.log(item);
		temp = {"name":item.product.name,"price":item.product.unit_sale_price,"quantity":item.quantity,"sku":item.product.sku_code};
		obj_to_push["transactionProducts"].push(temp);
	});
}
window.dataLayer = window.dataLayer || [];
dataLayer.push(obj_to_push);
</script>  
1 Expert replyverified_user

Re: Ecommerce Data / DataLayer Not Pushing to Analytics

Top Contributor
# 2
Top Contributor
Hi there,
a couple points about
1- Refer to the data layer specification for Enhanced eCommerce for GTM https://developers.google.com/tag-manager/enhanced-ecommerce
2- don't use "universal_variable" it's a reserved name for other tag management systems
VP & Chief Evangelist at Hub'Scan | Contact me
Level 80 Digital Analytics Warrior, KPI Therapist and Keeper of the One True Tagging Plan