Code Monkey home page Code Monkey logo

gtm-templates-knowit-experience / gtm-ga4-ecom-items-to-string-sum-values-variable Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 410 KB

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

License: Apache License 2.0

Smarty 100.00%
google-tag-manager gtm google-analytics-4 ga4 google-analytics

gtm-ga4-ecom-items-to-string-sum-values-variable's Introduction

GA4 Ecommerce Items to String or Sum Item Values - Web Variable

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).

This 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

Related Information

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

Variable Functionality in Detail

Select Input Method

Input can either be GA4 Ecommerce Data Layer or Variable. Select Input Method

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

Potential use cases

  • Create Ecommerce value or a fallback value if the implemented value fails.
  • Create **Event Scoped strings from Items in cases where you need this information both for Items and Event Scope.
  • Create Strings from Items for use in marketing tools (e.g. Floodlight).

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

gtm-ga4-ecom-items-to-string-sum-values-variable's People

Contributors

eivindsavio avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.