GA4 Event Tracking Series ⑤ —— Custom Events (Attributes Method) | BCS GA4 Event Tracking Series ⑤ —— Custom Events (Attributes Method) | BCSBCS

GA4 Event Tracking Series ⑤ —— Custom Events (Attributes Method)

Google Analytics BCS 2 years ago (2023-01-31) 1993 Views 0 Comments

Update time: January 13, 2025

This article introduces how to do custom event tracking through Attributes Method, which is what I recommend most.

Attributes Method is to locate through the attributes of the page, such as class, id, text, url, etc.

  • Be sure to choose an attribute with a unique value. If the value of a class at a certain location is unique, then just use that class to locate it.
  • If not, then use multiple attributes at the same time to ensure that it is unique, otherwise clicks in other locations will also trigger, resulting in inaccurate event tracking. If the value of class in a certain position is not unique and two positions require this class, then add another attribute, such as text, and use the class and text attributes at the same time to locate the tracked position.

Suppose I want to use the attributes method to track events at this location:

GA4 Event Tracking Series ⑤ —— Custom Events (Attributes Method)

Step 1 : Enable Built-In Variables

First enable some Built-In Variables, which will automatically get attributes to variables in GTM.

In GTM , click「Variables」——「Configure」,Check these Built-In Variables of click:

GA4 Event Tracking Series ⑤ —— Custom Events (Attributes Method)

The positions of these Built-In Variables in the source code are as follows:

GA4 Event Tracking Series ⑤ —— Custom Events (Attributes Method)

  • Click ID is ad.
  • Click Classes is de.

If you have already enabled it, you can ignore this step.

Step 2 : Set Up the Trigger

View the source code of the tracked location:

GA4 Event Tracking Series ⑤ —— Custom Events (Attributes Method)

We can know that the Click URL is https://www.bbccss.com/contact-me, and the Click Text is Contract Me, we can use these two attributes for trigger positioning.

 

In GTM , click「Triggers」——「New」——「Choose a trigger type to begin setup…」——「Click – All Elements」,Name it “Contract Me”, and make the following settings:

GA4 Event Tracking Series ⑤ —— Custom Events (Attributes Method)

 

Note: If Click URL or Click Text is unique, then you only need to use one; what I demonstrate here is to use two, and two can ensure uniqueness.

Step 3 : Set Up the Tags

In GTM , click「Tags」——「New」——「Choose a tags type to begin setup…」——「Google Analytics: GA4 Event」,Name it “GA4-Event-Contract Me (Attributes Method)”, and make the following settings:

GA4 Event Tracking Series ⑤ —— Custom Events (Attributes Method)

 

I just set the event name contract_me_attribute_method without setting the event parameters.

Note:If you have set event parameters, you also need to register it in GA4‘s Custom definitions before it can be used in GA4.

 

Step 4 : Preview and Publish

Next is the Preview test:

GA4 Event Tracking Series ⑤ —— Custom Events (Attributes Method)

Tags is triggered and can be published.

Read More:

Step 5 : Verify Data in Reports

Generally, after 24 hours, we can see the data in GA4, such as:GA4 Event Tracking Series ⑤ —— Custom Events (Attributes Method)

 

 

 

Read More: 


If you don't understand, You can leave a comment below.
Like (1)
Post my comment
Cancel comment
Expression Bold Strikethrough Center Italic

Hi, you need to fill in your nickname and email!

  • Nickname (required)
  • Email (required)
  • Website