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>
     $(".g-mono").click(function(){
    dataLayer.push({
   event:"click-ga",
   eventCategory:"Click",
   eventAction:"HomePage",
      eventLabel:"Test"
}); 
})
</script>
</span>

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

Save!

5、Preview

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 or email me (haran.huang@ichdata.com).
Tags ,
Was this article helpful to you? Yes No

How can we help?

Post my comment
Cancel comment
Expression Texture Bold Strikethrough Center Italic Sign in

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

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