Blogs
How to set Set up Google Analytics 4 events with Tag Manager?
How to set Set up Google Analytics 4 events with Tag Manager?
Setting up Google Analytics 4 (GA4) events with Google Tag Manager (GTM) involves several steps. Here’s a detailed guide to help you through the process:
- Prerequisites
- Google Tag Manager Account: Make sure you have a GTM account and container set up for your website.
- Google Analytics 4 Property: Ensure you have a GA4 property created.
- Step-by-Step Guide
- Step 1: Set Up Google Analytics 4 in Google Tag Manager
- Create a GA4 Configuration Tag:
- Go to your GTM account.
- Click on Tags in the left-hand menu.
- Click New and name your tag (e.g., GA4 Configuration).
- Click on Tag Configuration and select Google Analytics: GA4 Configuration.
- Enter your Measurement ID from your GA4 property (found in GA4 under Admin > Data Streams > Web > Measurement ID).
- Configure any additional settings if needed (e.g., sending user ID).
- Set the trigger to All Pages to fire the tag on every page.
- Click Save.
- Step 2: Create a New GA4 Event Tag
- Create a New Tag:
- In GTM, click on Tags.
- Click New and name your tag (e.g., GA4 Event - Button Click).
- Click on Tag Configuration and select Google Analytics: GA4 Event.
- Configure the Event Tag:
- Select your previously created GA4 Configuration Tag from the dropdown.
- Enter the Event Name (e.g., button_click).
- Under Event Parameters, you can add parameters that provide more information about the event. Click Add Row to add a parameter.
- Example: Parameter Name: button_text, Value: {{Click Text}} (You can use GTM variables here).
- Click Triggering and choose an appropriate trigger for the event (e.g., a button click trigger).
- Step 4: Preview and Test
- Preview Your Changes:
- Click the Preview button in GTM to enter preview mode.
- Enter the URL of your website to start the preview mode.
- Interact with your website to test if the event fires correctly.
- Check the Tags Fired section to see if your GA4 event tag fired as expected.
- Verify in GA4 DebugView:
- In GA4, go to the DebugView (found under Configure > DebugView) to see real-time event tracking.
- Ensure your custom events appear as expected.
- Create a Trigger:
- Go to Triggers in GTM.
- Click New and name it Submit Button Click.
- Click Trigger Configuration and select Click—All Elements.
- Configure the trigger:
- Choose Some Clicks.
- Set the condition: Click ID equals submit-button.
- Save the trigger.
- Step 5: Publish Your Container
- Submit Changes:
- Once you have verified that the event is firing correctly, go back to GTM.
- Click on Submit to publish your container changes.
- Provide a descriptive version name and notes, then click Publish.
- Example Event Setup
- Let's say you want to track clicks on a specific button with the ID submit-button.
- Create the GA4 Event Tag:
- Go to Tags.
- Click New and name it GA4 Event: Submit Button Click.
- Choose Google Analytics: GA4 Event.
- Select your GA4 Configuration Tag.
- Event Name: submit_click.
- Add parameters if needed.
- Choose the Submit Button Click trigger.
- Save the tag.
- By following these steps, you can set up and track custom events in Google Analytics 4 using Google Tag Manager.
- Step 3: Set Up Triggers
- Create a Trigger:
- Go to Triggers in GTM.
- Click New and name your trigger (e.g., Button Click).
- Click on Trigger Configuration and select Click—All Elements or Click—Just Links, depending on your needs.
- Configure the trigger to fire based on your criteria (e.g., clicks on a specific button with a certain class or ID).