Skip to content

Instantly share code, notes, and snippets.

@zguillez
Created February 22, 2023 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zguillez/8a20b4cebf811f132e6d7cdfc33c67ab to your computer and use it in GitHub Desktop.
Save zguillez/8a20b4cebf811f132e6d7cdfc33c67ab to your computer and use it in GitHub Desktop.
Get variable from dataLayer event
function() {
for (var i=0; i<dataLayer.length; i++) {
if (dataLayer[i][0]==='event' && dataLayer[i][1]==='view_item') {
return dataLayer[i][2].items[0].id;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment