I'm working with Enhanced Ecommerce at the moment; getting data from a site for Google Analytics but not everything is working.
The cart tracking (payment and shipping) is working and I can see this on Google Analytics, but Tracking Product Clicks, Measuring Views of Products, Tracking Additions to Cart, and Tracking Removals from Cart are not working as they should.
When I load certain parts of the pages, the Data Layer is not populated with any data using the following code:
//Tracking Product Clicks
dataLayer.push({
"event":"EEproductClick",
"ecommerce": {
"currencyCode": curr,
"click": {
"actionField": {"list":"category" },
"products": [{
"id": pdc,
"name": GarmName,
"price": prix,
"brand": "MyBrand",
"category": ""
}]
}
}
});
//End
//Measuring Views of Product Details
dataLayer.push({
"ecommerce": {
"currencyCode":curr,
"detail": {
"actionField": {"list":""}, //optional list property
"products": [{
"id":pdc,
"name":GarmName,
"price":prix,
// "brand":"Boss",
// "category":"Men/Clothing/T-Shirts",
// "variant":"black"
}]
}
}
});
//End
//Tracking adds to cart
dataLayer.push({
"event":"EEaddToCart",
"ecommerce": {
"currencyCode": curr,
"add": {
"products": [{
"id": pdc,
"name": GarmName,
"price": prix,
"brand": "MyBrand",
// "category":"Men/Clothing/T-Shirts",
// "variant":"black", //optional, if there is a variant of the product
"quantity":1
}]
}
}
});
//End
//Tracking removes from cart
dataLayer.push({
"event":"EEremoveFromCart",
"ecommerce": {
"currencyCode": curr,
"remove": {
"products": [{
"id": pdc,
"name": GarmName,
"price": prix,
"brand": "MyBrand",
// "category":"Men/Clothing/T-Shirts",
// "variant":"black", //optional, if there is a variant of the product
// "quantity":1
}]
}
}
});
//End
I'm currently using the following code which does populate the data layer, but using Google Tag Manager, no data is being sent to Google Analytics except the purchase process.
//Measuring Views of Product Details
dataLayer.push({
event: 'ProductView',
ecommerce: {
detail: {
actionField: {
list: 'Search Results'
},
products: [{
id: pdc,
name: GarmName,
// category: 'guides/google-tag-manager/enhanced-ecommerce',
// variant: 'Text',
// brand: 'SIMO AHAVA',
// dimension3: 'Ecommerce',
// metric5: 12,
// metric6: 1002
}]
}
}
});
//END
//Measuring Product Clicks
dataLayer.push({
event: 'EE_ProductView',
'ecommerce': {
'detail': {
'actionField': {},
'products': [{
'name': GarmName,
'price': prix,
'id': pdc
}]
}
}
})
//End
//Measuring Additions or Removals from a Shopping Cart
dataLayer.push({
'event': 'addToCart',
'ecommerce': {
'currencyCode': curr,
'add': {
'products': [{
'name': GarmName,
'id': pdc,
'price': prix,
'quantity': 1
}]
}
}
});
//End
// Measure the removal of a product from a shopping cart.
dataLayer.push({
'event': 'removeFromCart',
'ecommerce': {
'remove': {
'products': [{
'name': GarmName,
'id': pdc,
'price': prix,
'quantity': 1
}]
}
}
});
//End
What am I doing wrong for one set of code to work and another to not? And how can I get GTM to push the data it is receiving to Google Analytics, please?
Many Thanks
EDIT: I've deleted my code and GTM/GA tags and rewritten them all and it seems to now be working to an extent. Still getting the same issues though so will look into this further