Last active
December 1, 2016 15:33
-
-
Save vhsu/bdf00cfdff2cff267f9f09d7244359b9 to your computer and use it in GitHub Desktop.
Get Datalyer value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get single datalayer value from gtm in vanilla javascript | |
google_tag_manager["GTM-XXXXXXX"].dataLayer.get('variable') | |
// Retrieve value from google tag manager datalayer object in vanilla javascript | |
google_tag_manager["GTM-XXXXXXX"].dataLayer.get('variable')['purchase']['actionField']['revenue'] | |
// To fetch the value from a javacript variable inside gtm of custom html you would use the following code from the same object | |
variable.purchase.actionField.revenue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment