GA4 Ecommerce Items to String or Sum Item Values is a Google Tag Manager Variable Template (Web).
This Variable for Google Tag Manager (Web) turns Google Analytics 4 (GA4) Ecommerce Item array (e.g. [{item_id: ’12’, quantity: 1},{item_id: ’34’, quantity: 2}]) into a string (e.g. ’12|34′), or sums Item Values (e.g 3). When summing values you can choose to multiply the value with quantity (e.g. [{price: 10, quantity: 1},{price: 20, quantity: 2}]) which will give the result 50).
The Template is available in the Google Tag Manager Template Gallery.
Variable Functionality Overview
- Select Input Method
- GA4 Ecommerce Data Layer
- Variable
- Select Mapping Method
- GA4 Standard Ecommerce Events
- Custom Mapping
- Select Item Parameter Type & Action
- Create String from Item Parameter
- Standard Item Parameters
- Custom Item Parameters
- Choose Delimiter
- Return Unique Items
- Sum Values from Item Parameter
- Standard Item Parameters
- Custom Item Parameters
- Multiply Item Value with Item Quantity
- Create String from Item Parameter
Full documentation of the Template can be found on Github.
Related Information
A similiar Variable for Google Tag Manager (Server) does also exist:
Possible use cases
- Use the Variable to create Ecommerce value by multiplying price with quantity (if this is missing in the implementation)
- If you need to track data both on Item Scope and Event Scope, use this Variable to create Event Scoped data.
- Send Items data as a string to ex. Floodlight for marketing purposes.