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, completing a purchase, adding a product to the cart, or starting a checkout. Event measurement is interesting not only for web shops, but also for business websites. For example: measuring completed 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.
Table of Contents
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 are going to track events server side.
We assume you have already created a Google Tag Manager account. If you are looking for a description for creating a Google Tag Manager account, check out this article.
We show 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 e-commerce events, you need a GA4 datalayer. You can install these 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 the business events, you don't need a special datalayer, using the data automatically available in Google Tag Manager. In the remainder of this blog, we will look specifically at measuring e-commerce events. Want to learn 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 at '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: Events - Equals - [name of trigger]. Click "Save.
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 correctly configured the data layer, it sends all kinds of additional data about the products to GTM. You can use these 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 the Google Tag Manager preview mode, see how your DataLayer is structured. 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 "New" here. Select "Variable for data layer. Here you can extract the values of the variables from the datalayer so you can use them for your tracking. Name the variables in the Data Layer Variable Name field.
Naming Variables works as follows: you name the parameter you want to track by naming the route in the datalayer code from left to right, separated by a dot. What do we mean by that? 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 sample mode, you can discover how to name each parameter as a variable in GTM. In the example below, you can see that the price of a product as e-commerce comes in as price. Therefore, we should also call it as a variable ecommerce.price.
B2B event creation in Google Tag Manager
To track B2B events with Google Tag Manager, start by using built-in variables that Google Tag Manager (GTM) already provides. These variables automatically capture actions such as filling in form fields or clicking on a phone number. The advantage 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. This can range from clicking on a phone number to filling out a contact form.
Then you set 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 completed form 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 Google Analytics: GA4 Event type. This is where 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. Taking advantage of enhanced conversions requires specific events.