How do you create (E-commerce) events in Google Tag Manager?
If you have an online store, tracking the performance of your online store is essential to optimize your sales strategy. With Google Tag Manager, you can create GA4 e-commerce events to track, for example, the completion of a purchase, adding a product to the cart, or starting a checkout. Measuring events is not only interesting for web shops, but also for business websites. For example: measuring completed job application forms, or demo requests.
In this blog, we will explain step by step how to create events in the web container in Google Tag Manager so that you can get better insight into the performance of your web shop/website and improve your marketing strategy to achieve more sales and growth.
See the entire GA4 Server Side Tracking setup for more information.
Note: This blog is not about server side event tagging. The events are created client side in this blog. In the next parts of the GA4 implementation series, we will be tracking events server side.
We assume that you have already created a Google Tag Manager account. If you are looking for a description on how to create a Google Tag Manager account, check out this article.
We'll show you examples for building events in this blog. Want to see preset GTM templates where all the events are already set up for you? Then check out our TAGGRS Template Gallery.
What events can you measure?
There are currently 14 e-commerce events (events) that you can measure. Below is a table of which events these are and their description.
GA4 action | Description |
view_item_list | Someone sees a product listing. |
select_item | Someone selects a product within the overview. |
view_item | Someone visits a product page. |
add_to_cart | Someone adds a product to the shopping cart. |
remove_from_cart | Someone removes a product from the shopping cart. |
view_cart | Someone looks at the shopping cart. |
add_to_wishlist | Someone adds a product to a wishlist. |
start_checkout | Someone starts to checkout. |
add_shipping_info | Someone chooses a shipping option. |
add_payment_info | Someone chooses a payment option. |
purchase | Someone placed an order. |
refund | Someone canceled an order (in part). |
view_promotion | Someone looked at a promotion. |
select_promotion | Someone selected a promotion. |
There are also numerous options for tracking other events:
GA4 action | Description |
application | Someone fills out an application form. |
call_to_clicks | Someone clicks on a phone number on your website. |
call_to_mail | Someone clicks on an e-mail address on your website. |
form | Someone fills out a form on your website. |
demo_request | Someone requests a demo appointment on your website. |
For the e-commerce events you need a GA4 datalayer. You can install this manually using the official GA4 documentation, or you can use a plugin or extension. For example:
- Woocommerce/Wordpress: TAGGRS plugin (note! is not in wordpress plugin store)
- Lightspeed / Magento: TAGGRS Lightspeed App
- Magento 2: Anowave extension
- Shopify: Analizify
- Shopware: Google Analytics 4 for shopware 6
- Custom: create your own GA4 datalayer
For business events, you don't need a special data layer, in that you can use the data that is automatically available in Google Tag Manager. In the remainder of this blog we will specifically discuss measuring e-commerce events. Want to know more about creating custom events for your business website. Then watch this video. Once you have the events set up, continue to this blog.
Creating e-commerce events in Google Tag Manager
Once you've determined which events you want to measure, it's time to create the e-commerce events in Google Tag Manager.
Step 1: Create Trigger
Go to the workspace in GTM and open the 'Triggers' tab and click 'New'.
Step 2: Choose type of trigger
Click the pencil under 'Trigger Configurations' and choose 'Custom Event' as the trigger type (under other).
Step 3: Add event
Under 'Name of event' enter the name of the event you want to measure (exactly as named in the datalayer, use debug mode to find out). Then select 'Some custom events'. Enter here: Event - Equals -
You have now created an e-commerce event on Google Tag Manager, good job!
Step 4: Create additional variables (optional)
You can send additional data to GA4 in addition to the events. When you have configured the data layer correctly, it sends all kinds of additional data about the products to GTM. You can use this for more insight. The following variables can be sent along with the datalayer:
Datalayer variable | Description |
currency | Currency of price. |
value | The value associated with the event. |
items | Products associated with the event. |
transaction_id | Unique ID for the transaction. Required for purchase and refund events. |
coupon | Discount coupon associated with the event. |
affiliation | The store or affiliate where the purchase took place. |
payment_type | The payment method sent with add_payment_info |
shipping | Shipping costs included in total sales of purchase. |
shipping_tier | The shipping category used with add_shipping_info. |
tax | How much tax is included in the total sales of the purchase. |
This list is not all-encompassing, but to keep it organized, we limit ourselves to this list.
Note! These variables are based on a standard GA4 DataLayer. In Google Tag Manager preview mode, see how your DataLayer is built. In the video below, we show you how to do this.
To send these parameters along with the events we created in steps 2 and 3, we first go to variables in GTM:
Click on 'New' here . Select 'Variable for data layer'. Here you can extract the values of the variables from the data layer so that you can use them for your tracking. Name the variables in the 'Name of variable for data layer' field .
Naming variables works like this: you name the parameter you want to track by naming its path in the datalayer code from left to right, separated by a dot. What do we mean by this? Suppose we want to measure the paramater 'value' in this datalayer:
We then call it ecommerce.value, because the leftmost parameter is e-commerce and on the next line is value.
By checking how the Data Layer comes in in the example mode, you can discover for each parameter how to name it as a variable in GTM. In the example below, you can see that the price of a product comes in as ecommerce as price. Therefore, we should also name it as a variable ecommerce.price.
Creating B2B events in Google Tag Manager
To track B2B events with Google Tag Manager, start by using built-in variables that GTM already provides. These variables automatically capture actions such as form fields being filled out or clicking on a phone number. The benefit of this is that you often don't need to add an additional datalayer to track these events, which streamlines the process.
First, go to the Variables section in GTM, where you'll find the Built-in Variables option. Here you click Configure to select the variables you need for tracking your events. These can range from clicking on a phone number to filling out a contact form.
Next, set up triggers for the B2B events you want to measure. You do this by going to Triggers and creating a new trigger. Give the trigger a clear name, such as GA4 Event contact form, and choose Form submission as the trigger type. Here you select All Forms to ensure that the trigger becomes active for every form completed on your site.
After setting up your triggers, the next step is to create the tags associated with these triggers. You go to Tags and create a new tag. Choose the type of Google Analytics: GA4 Event. Here you enter your Measurement ID and give the event a name, such as contact form. Then you link this tag to the trigger you created earlier.
What's next?
You have now created events and variables so you can use e-commerce data for measurements in GA4 or other platforms. The next step in the GA4 implementation series will teach you how to send these events and variables to GA4 by creating a GA4 Event tag.
Frequently asked questions creating events
Is it possible to implement Server Side Tracking without events, for example just with a thank you page?
Absolutely, it is possible to apply Server Side Tracking without using events, as in the case of a thank you page. However, it is important to note that in such a configuration the functionality for enhanced conversions will not be available. Specific events are required to take advantage of enhanced conversions.