Skip to content

Instantly share code, notes, and snippets.

@marcusRB
Created October 14, 2018 10:00
Show Gist options
  • Select an option

  • Save marcusRB/90fd00fb8faa641448862b6daaa3f4e9 to your computer and use it in GitHub Desktop.

Select an option

Save marcusRB/90fd00fb8faa641448862b6daaa3f4e9 to your computer and use it in GitHub Desktop.
EEC_productName
/* EEC ProductsName - Custom JS for GTM - update 09-2018 MR//PD
- EEC dataExtract for FBads, ADW, and 3rdParty
- This function create new array and interact with it
- Combine differents cases, when exist '/p/' product URL, '/c/' category URL, '/search/' searchQuery in URL, or event 'addToCart'
-
*/
function() {
try{
if ({{Page Path}}.indexOf('/p/') != -1 && {{Event}} != 'addToCart'){
var products = {{dlv - ecommerce.detail.products}};
return products.map(function(prod) { return prod.name; }).join();
}else if ({{Page Path}}.indexOf('/c/') != -1 && {{Event}} != 'addToCart'){
var products = {{dlv - ecommerce.detail.products}};
return products.map(function(prod) { return prod.name; }).join();
}else if ({{Page Path}}.indexOf('search') != -1 && {{Event}} != 'addToCart'){
var products = {{dlv - ecommerce.detail.products}};
return products.map(function(prod) { return prod.name; }).join();
}else if ({{Event}} == 'addToCart'){
var prods = {{dlv - EEC ecommerce.add.products}}[0];
return prods.name;
}
} catch(e){
window.console(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment