• Hi Guys,
    I can’t seem to find the correct way to pull out certain information from the DataLayer.

    I am struggling to pull Name, Currency, Category, SKU etc out.

    I want to create a variable in GTM. This part i know, but what is the dataLayer Variable Name

    Is it products.name and so on i.e. products.id products.category etc

    Is this the correct way to get Currency on product impressions ‘currencyCode’

    I presume when I track products on cart, i can use the same variables but just use a loop so it pushes all the products name, prices, id etc

    Any help is appreciated

    Thanks

Viewing 1 replies (of 1 total)
  • Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi,

    I assume you have enabled enhanced ecommerce tracking in my plugin as this can bring you the most ecommerce data into the data layer.

    Currency code: use ecommerce.currencyCode

    As for product data, you will need to create multiple GTM variables or use a custom JS variable with multiple if() statements. For example this is how you can pull the name of the product that has been added to the cart:

    ecommerce.add.products.0.name

    If you are using a custom JS variable, you need to change this to

    ecommerce.add.products[0].name

    You can pull SKU/ID by changing name in the above example to id. Or you can use price or category as well.

    For other ecommerce actions you can use click, detail or remove instead of add.
    You may also use actions like checkout or purchase but since more than one product can be part of a cart, you will need to create a code that loops through the products array instead of just referencing the first item (with the 0 index).

    I hope that helps.

Viewing 1 replies (of 1 total)
  • The topic ‘Pulling Variable Name’ is closed to new replies.