This section introduces another method of tracking events——the method of binding classes. The advantage of this method is that you do event tracking later. You only need to create a tag bound to the class to implement event tracking.
Suppose what I want to track is here, click on the homepage:
Setup Process
1、Find class
Move the mouse to the position you want to track, then right-click and select Inspect:
Then copy the value of class.
2、Create A Tag
Create a custom HTML tag and name it: Event Tracking——Class,Then copy the following code into it.
<span style="font-size: 12pt;"><script> $(".g-mono").click(function(){ dataLayer.push({ event:"click-ga", eventCategory:"Click", eventAction:"HomePage", eventLabel:"Test" }); }) </script> </span>
Trigger Select All Pages:
The place surrounded by the red box in the figure above is to fill in the class. Fill in whatever your class is. Others such as Category, Action and Label can be customized later.
2、Create A Trigger
Create a trigger for a Custom Event:
The event name depends on what you called the event in the previous step. It must be consistent, here is click-ga
3、Create data layer variables
Create a data layer variable, and then make the following settings. The Data Layer Variable Name is the name that is defined in the first step, and must be consistent:
eventCategory, eventAction, eventLabel, all three need to be created:
4、Create A Tag
Create a Tag and set it as follows:
Save!
5、Preview
Click Preview in the upper right corner to test.
The event was triggered.