Skip to content

Instantly share code, notes, and snippets.

@rgoytacaz
Created April 16, 2019 04:35
Show Gist options
  • Save rgoytacaz/1c2ec6c11c910c5e5b698dcefb63862d to your computer and use it in GitHub Desktop.
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.
//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