Created
April 16, 2019 04:35
-
-
Save rgoytacaz/1c2ec6c11c910c5e5b698dcefb63862d to your computer and use it in GitHub Desktop.
function that returns a string of productIds separated by commas from dataLayer on orderPlaced page.
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
//function that returns a string of productIds separated by commas | |
for (var idx in dataLayer) { | |
if (dataLayer[idx].hasOwnProperty('ecommerce')){ | |
return dataLayer[idx].ecommerce.purchase.products.map(function(product){ return product.id }).join(',')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment