Title: Pulling Variable Name
Last modified: March 23, 2018

---

# Pulling Variable Name

 *  [mrsullivan](https://wordpress.org/support/users/mrsullivan/)
 * (@mrsullivan)
 * [8 years ago](https://wordpress.org/support/topic/pulling-variable-name/)
 * 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](https://wordpress.org/support/users/duracelltomi/)
 * (@duracelltomi)
 * [8 years ago](https://wordpress.org/support/topic/pulling-variable-name/#post-10109834)
 * 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.

 * ![](https://ps.w.org/duracelltomi-google-tag-manager/assets/icon-256x256.png?
   rev=1708451)
 * [GTM4WP - A Google Tag Manager (GTM) plugin for WordPress](https://wordpress.org/plugins/duracelltomi-google-tag-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/duracelltomi-google-tag-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/duracelltomi-google-tag-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/duracelltomi-google-tag-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/duracelltomi-google-tag-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/duracelltomi-google-tag-manager/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Thomas Geiger](https://wordpress.org/support/users/duracelltomi/)
 * Last activity: [8 years ago](https://wordpress.org/support/topic/pulling-variable-name/#post-10109834)
 * Status: not resolved