Reputation: 3
I’m trying to implement Google Tag Manager dataLayer with the help of a developer. The devs are saying that everything is implemented the way it should be, but I can’t see the dataLayer information within the GTM debugger. I want to set Enhanced eCommerce GA and I have sent the documentation over, but it is still not working for some reason.
Here is the code that I can see once I check the page source. It's on the product page:
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-M8VNL5N');</script>
<!-- End Google Tag Manager -->
<script>
dataLayer.push({
'event': ‘ProductView'
'ecommerce': {
'detail': {
'actionField': {},
'products': [{
'name': ‘Product Name’,
'id': '58141',
'price': '545.00',
'brand': ‘Product Brand’,
'category': ‘Product Category’,
}]
}
}
});
</script>
Can you guys see something that it’s not supposed to be like that? I’m not good with JS yet and I can’t find where the issue is coming from.
I would greatly appreciate your help!
Best!
Upvotes: 0
Views: 2188
Reputation: 5198
Try this, there were weird quotes and missing commas.
dataLayer.push({
'event': 'ProductView', //comman was missing here and weird quote
'ecommerce': {
'detail': {
'actionField': {},
'products': [{
'name': 'Product Name', //weird quote here
'id': '58141',
'price': '545.00',
'brand': 'Product Brand', //weird quote
'category': 'Product Category', //weird quote
}]
}
}
});
Result:
Upvotes: 1