Skip to content

Variable Template (Server) for Google Tag Manager that turns the 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).

License

Notifications You must be signed in to change notification settings

gtm-templates-knowit-experience/sgtm-ecom-items-to-string-sum-values-variable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ecommerce Items to String or Sum Item Values - SGTM Variable

This Variable for Google Tag Manager Server-side (SGTM) turns the 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).

This Template is available in the Google Tag Manager Template Gallery.

Variable Functionality Overview

  • 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

Related Information

A similiar Variable for Google Tag Manager (Web) does also exist:

Variable Functionality in Detail

Select Mapping Method

Mapping can be done using GA4 Standard Ecommerce Events or Custom Mapping.

Mapping simply means that only values that are mapped should return a result.

Mapping using GA4 Standard Ecommerce Events

Image shows how to map using GA4 Standard Ecommerce Events.

Selecting GA4 Standard Ecommerce Events

Custom Mapping

Image shows how to do Custom Mapping.

  • Type in the value in the Custom Parameter Field that should be matched against the selected Variable. This means the Selected Variable should be able to return the value in this field.
  • Select Variable to map against.

Selecting Custom Mapping

Create Strings from Item Parameters

Image shows how to Create a String from a Custom Item Parameter. Choosing Standard Item Parameters can be done using the Select Item Type dropdown.

In the example Unique Items are returned. E.g. [{item_color: 'Blue'},{item_color: 'Red'},{item_color: 'Blue'}] will return the result 'Blue|Red'.

Create Strings from Item Parameters

Sum Item Values from Item Parameters

Image shows how to Sum Item Values using Standard Item Parameters. You can also use Custom Item Parameters to sum values.

In this example price will be multiplied with quantity.

Sum Values from Item Parameters

Images of the Variable

Image shows how to Create Strings using Custom Mapping and Custom Item Parameters.

Create Strings using Custom Mapping and Custom Item Parameters

Image shows how to Sum Item Values using GA4 Standard Ecommerce Events and Standard Item Parameters.

Sum Item Values using GA4 Standard Ecommerce Events and Standard Item Parameters

About

Variable Template (Server) for Google Tag Manager that turns the 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).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages