Skip to content

Instantly share code, notes, and snippets.

@stefanatcroud
Created August 1, 2023 10:48
Show Gist options
  • Save stefanatcroud/dd5eecbbfd513e62bd1e31371b904521 to your computer and use it in GitHub Desktop.
Save stefanatcroud/dd5eecbbfd513e62bd1e31371b904521 to your computer and use it in GitHub Desktop.
Script for GTM to use in a Custom JavaScript variable that returns a vertical bar separated list of item.id's taken from GA4 ecommerce data layer
function () {
return google_tag_manager[{{Container ID}}].dataLayer.get("ecommerce.items").map(function(a){return a.item_id}).join("|")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment