Digital Marketing
Google Tag Manager Integration

Enhanced eCommerce Setup

15min

Enhanced eCommerce Setup for GA4

1. Create variables in Google Tag Manager

We need to create 3 variables for GA4 in the Google Tag Manager. For this, go to its dashboard and click on the Variables:

Document image


Next, click on the New button from the User-Defined Variables to add a variable.

Variable 1 - Ecommerce Transaction ID

  • In the next screen, enter the variable name as – Ecommerce Transaction ID
  • Now, hover over the Variable Configuration section and click on the pencil-like icon.
  • In the Choose variable type screen, choose the variable type as – Data Layer Variable:
Document image

  • Enter the Data Variable Name as - ecommerce.purchase.actionField.id
  • In Data Layer Version, select Version 2 from the drop down and click on the Save button.

Variable 2 - Ecommerce Revenue

  • Click on the New button from the User-Defined Variables to add the new variable.
  • In the next screen, enter the variable name as – Ecommerce Revenue
  • Now, hover over the Variable Configuration section and click on the pencil-like icon.
  • In the Choose variable type screen, choose the variable type as – Data Layer Variable.
  • Enter the Data Variable Name as - ecommerce.purchase.actionField.revenue
  • In Data Layer Version, select Version 2 from the drop-down and click on the Save button.
Document image


Variable 3 - GA4 Ecommerce DataLayer

  • Click on the New button from the User-Defined Variables to add the variable.
  • In the next screen, enter the variable name as – GA4 Ecommerce DataLayer
  • Now, hover over the Variable Configuration section and click on the pencil-like icon.
  • In the Choose variable type screen, choose the variable type as – Data Layer Variable.
  • Enter the Data Variable Name as - ecommerce.items
  • In Data Layer Version, select Version 2 from the drop-down and click on the Save button.
Document image


2. Create Tags in Google Tag Manager

Once you are done with creating variables, it is now time to create tags in the Google Tag Manager For GA4.

From your workspace, click on the Tags option and then click on the New button.

Document image


Configure a tag with the details as displayed below:

Document image

  • Enter the tag title – Google Tag
  • Under Tag Configuration, click on the pencil-like icon and then choose tag type as – Google Tag
  • Enter the Measurement ID that you have copied from the third step of the GA4 setup using GTM in the Tag ID field.
  • Under Triggering, click on the pencil-like .icon and then choose tag type as – All Pages.
  • Click on the Save button from the top-right corner.

Now let's create a tag for Add to Cart event as per the below steps:

Document image

  • Enter the tag title – GA4 Add to Cart
  • Under Tag Configuration, click on the pencil like icon and then choose tag type as – Google Analytics: GA4 Event
  • Enter the Measurement ID that you have copied from the third step of the GA4 setup using GTM in the Tag ID field.
  • Under Event Name write – add_to_cart
  • Now, click on the Event Parameters and then on Add Row button.
    • Parameter Name - items
    • Value - click on plus icon and select the "GA4 Ecommerce DataLayer" variable.

Now, under Triggering, click on the pencil like icon and then click on the ‘+’ icon to add a trigger.

Document image


In the next screen, enter the trigger details as below:

  • Enter trigger name as – GA4 Add to Cart
  • Under the Trigger Configuration, click the pencil like icon and then choose the trigger type as – Custom Event
  • Write Event Name as – add_to_cart
  • Under ‘This trigger fires on’ select – All Custom Events
  • Click on the Save.

Your Trigger Screen should look like the below –

Document image


Similarly, you can create 5 other tags and triggers with the same setting. All you have to do is follow the below table:

Tag Title

Action (Tag)

Trigger Names

Event Name (Trigger)

View Item List

view_item_list

GA3 impressions

productImpression

View Item List

view_item_list

GA3 impressions

productImpression

Select Item

select_item

Select Item

select_item

View Item

view_item

View Item

view_item

Remove from Cart

remove_from_cart

Remove from Cart

remove_from_cart

Begin Checkout

begin_checkout

Begin Checkout

begin_checkout

Now, the next three tags are IMPORTANT for generating data at Google Analytics. So, let's start creating the first tag for purchase event as per the below steps:

Document image

  • Enter the tag title – GA4 Purchase
  • Under Tag Configuration, click on the pencil like icon and then choose tag type as – Google Analytics: GA4 Event
  • Enter the Measurement ID that you have copied from the third step of the GA4 setup using GTM in the Tag ID field.
  • Under Event Name write – purchase
  • Now, click on the Event Parameters and then add 4 rows by clicking on Add Row button. Add the parameters below:

Parameter

Value

value

select variable - Ecommerce Revenue

transaction_id

select variable - Ecommerce Transaction ID

currency

enter - USD

items

select variable - GA4 Ecommerce DataLayer

Now, under Triggering, click on the pencil like icon and then click on the ‘+’ icon to add a trigger.

Document image


In the next screen, enter the trigger details as below:

  • Enter trigger name as – GA4 Purchase
  • Under the Trigger Configuration, click the pencil like icon and then choose the trigger type as – Custom Event
  • Write Event Name as – purchase
  • Under ‘This trigger fires on’ select – All Custom Events
  • Click on the Save.

Your Trigger Screen should look like the below –

Document image


You can create a tag for "Add Shipping Info" event as displayed below images and save the settings:

  • Enter the tag title – GA4 add_shipping_info
  • Under Tag Configuration, click on the pencil like icon and then choose tag type as – Google Analytics: GA4 Event
  • Enter the Measurement ID that you have copied from the third step of the GA4 setup using GTM in the Tag ID field.
  • Under Event Name write – add_shipping_info
Document image


Now, under Triggering, click on the pencil like icon and then click on the ‘+’ icon to add a trigger.

Document image


In the next screen, enter the trigger details as below:

  • Enter trigger name as – GA4 add_shipping_info
  • Under the Trigger Configuration, click the pencil like icon and then choose the trigger type as – Custom Event
  • Write Event Name as – add_shipping_info
  • Under ‘This trigger fires on’ select – All Custom Events
  • Click on the Save.
Trigger Configuration
Trigger Configuration


Similarly, create a tag for "Add Payment Info" event and save the settings:

  • Enter the tag title – GA4 add_payment_info
  • Under Tag Configuration, click on the pencil like icon and then choose tag type as – Google Analytics: GA4 Event
  • Enter the Measurement ID that you have copied from the third step of the GA4 setup using GTM in the Tag ID field
  • Under Event Name write – add_payment_info
Document image


Now, under Triggering, click on the pencil like icon and then click on the ‘+’ icon to add a trigger.

Document image


In the next screen, enter the trigger details as below:

  • Enter trigger name as – GA4 add_payment_info
  • Under the Trigger Configuration, click the pencil like icon and then choose the trigger type as – Custom Event
  • Write Event Name as – add_payment_info
  • Under ‘This trigger fires on’ select – All Custom Events
  • Click on the Save.
Trigger Configuration
Trigger Configuration