Creating Google Analytics 4 Event Tags
After setting up a Google Tag / GA4 configuration tag in the web container, you can also start configuring tags to create events that are sent to GA4 and your server container.
The very first tag you create is a tag that tracks when a visitor views a page.
Create a new tag in your web container
Give the tag a clear name such as "GA4 - page_view"
Click on Tag Configuration and select “Google Analytics: GA4 Event” from the list.
For Measurement ID, select the constant variable with your GA4 Data Stream Measurement ID.
For the event name use the name "page_view"
Use the event parameters dropdown and add a new parameter, use "event_id" as value and select your unique event id as variable
Select the trigger ""all pages - page view" and click save
Create a new tag in your web container
Give the tag a clear name such as "GA4 - DataLayer event interaction" (the text "datalayer event interaction" is interchangeable with the name of the event)
Click on tag configuration and select GA4-Event
For Measurement ID, select the constant variable with your GA4 Data Stream Measurement ID.
For the event name use a name that is appropriate for the datalayer event
Open the event parameters. Add an event parameter named ‘event_id’ with the value set to the Unique Event ID variable.
All other data from the DataLayer that you want to attach to an event as parameters can be retrieved by following these steps
Add a trigger, click on the plus sign to create a new trigger
For a DataLayer event, choose the orange option ‘Custom Event’ as the trigger configuration type.
As the name of the event, and as the name of the trigger itself, choose the name of the DataLayer event you want to trigger on.
Save the trigger
Create a new tag in your web container
Give the tag a clear name such as "GA4 - event name"
Click on Tag Configuration and select “Google Analytics: GA4 Event” from the list.
For Measurement ID, select the GA4 Measurement ID variable that you created.
For Event Name, enter “event_name”.
Open the event parameters. Add an event parameter named ‘event_id’ with the value set to the Unique Event ID variable.
Add a trigger, click on the plus sign to create a new trigger
Save the trigger and test
page_view
The very first tag you create is a tag that tracks when a visitor views a page.
Create a new tag in your web container
Give the tag a clear name such as "GA4 - page_view"
Click on Tag Configuration and select “Google Analytics: GA4 Event” from the list.
For Measurement ID, select the constant variable with your GA4 Data Stream Measurement ID.
For the event name use the name "page_view"
Use the event parameters dropdown and add a new parameter, use "event_id" as value and select your unique event id as variable
Select the trigger ""all pages - page view" and click save
DataLayer Events
Create a new tag in your web container
Give the tag a clear name such as "GA4 - DataLayer event interaction" (the text "datalayer event interaction" is interchangeable with the name of the event)
Click on tag configuration and select GA4-Event
For Measurement ID, select the constant variable with your GA4 Data Stream Measurement ID.
For the event name use a name that is appropriate for the datalayer event
DataLayer Event | GA4 event name |
---|---|
trytagging_view_item | view_item |
trytagging_view_item_list | view_item_list |
trytagging_select_item | select_item |
trytagging_add_to_cart | add_to_cart |
trytagging_view_cart | view_cart |
trytagging_remove_from_cart | remove_from_cart |
trytagging_begin_checkout | begin_checkout |
trytagging_add_shipment_info | add_shipment_info |
trytagging_add_payment_info | add_payment_info |
trytagging_purchase | purchase |
Open the event parameters. Add an event parameter named ‘event_id’ with the value set to the Unique Event ID variable.
All other data from the DataLayer that you want to attach to an event as parameters can be retrieved by following these steps
Add a trigger, click on the plus sign to create a new trigger
For a DataLayer event, choose the orange option ‘Custom Event’ as the trigger configuration type.
As the name of the event, and as the name of the trigger itself, choose the name of the DataLayer event you want to trigger on.
Save the trigger
Other Interactions
Create a new tag in your web container
Give the tag a clear name such as "GA4 - event name"
Click on Tag Configuration and select “Google Analytics: GA4 Event” from the list.
For Measurement ID, select the GA4 Measurement ID variable that you created.
For Event Name, enter “event_name”.
Open the event parameters. Add an event parameter named ‘event_id’ with the value set to the Unique Event ID variable.
Add a trigger, click on the plus sign to create a new trigger
Save the trigger and test
Updated on: 16/08/2024
Thank you!