1. Home
  2. Docs
  3. Google Tag Manager Guide
  4. Several Common Event Tracking Methods
  5. Method Of Binding Class

Method Of Binding Class

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:

Method Of Binding Class

Setup Process

1、Find class

Move the mouse to the position you want to track, then right-click and select Inspect:

Method Of Binding Class


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>

Trigger Select All Pages:

Method Of Binding Class

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:

Method Of Binding Class

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:

Method Of Binding Class

eventCategory, eventAction, eventLabel, all three need to be created:

Method Of Binding Class


4、Create A Tag

Create a Tag and set it as follows:

Method Of Binding Class



Click Preview in the upper right corner to test.

Method Of Binding Class


The event was triggered.

If you don't understand, You can leave a comment below.
Tags ,