Skip to content

Instantly share code, notes, and snippets.

@zguillez
Created February 22, 2023 11:13
Embed
What would you like to do?
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