Skip to content
Advertisement

Google Tag Manager returning undefined on dataLayer variable

I’m trying to create a dataLayer variable so I can push the product name into the event label.

The dataLayer push when a user adds a product to cart is:

JavaScript

I’ve tried to create a dataLayer variable with the following

JavaScript

This is returning undefined in preview mode when I do test add to carts.

Where am I going wrong?

Advertisement

Answer

You might need to change the DataLayer variable to

enter image description here

I can’t really remember where I saw about this.

But when fetching data through here.

It is not regular get products[0].name but products.0.name

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement