Step 1: Set Up Your Tag in GTM
First, log into your Google Tag Manager account. Navigate to the ‘Tags’ section and click on ‘New’ to create a new tag.
Configuring Your Tag
- Tag Type: Select ‘Google Analytics: GA4 Event’.
- Tag Configuration: Enter your GA4 Measurement ID, which you can find in your GA4 account under Admin Settings > Data Streams.
Step 2: Define Your Custom Event
Event Name: Choose a clear, descriptive name for your event using lowercase and underscores instead of spaces (e.g., ‘custom_event_name’).
Step 3: Set Up Triggering
This step involves specifying when your custom event should fire.
- Navigate to the ‘Triggers’ section in GTM and create a new trigger.
- Choose the trigger type as ‘All Elements’ and set it to fire on ‘Some Clicks’.
- Specify the conditions under which the trigger should fire, such as clicking a specific button. For instance, if your button has a CSS class named ‘CTA’, set the Click Class condition to ‘CTA’.
Step 4: Testing Your Setup
Before making your tag live, it’s crucial to test it:
- Preview Mode: Go to GTM and click on ‘Preview’. Enter the URL where your specified button is located and interact with your page as a user would.
- Debug View: Check the debug view in GA4 to see if your custom event is being recorded as expected.
Step 5: Publish Your Changes
Once you confirm that everything is set up correctly:
- Exit preview mode in GTM.
- Click on ‘Submit’ to publish your changes.
Within 24-48 hours, you should start seeing the data from your custom event appear in your GA4 account under the ‘Events’ section.