1. Home
  2. Docs
  3. Google Tag Manager Guide
  4. Several Common Event Tracking Methods
  5. ga-data Method(Bulk Event Tracking)

ga-data Method(Bulk Event Tracking)

This section describes how to do batch event tracking, that is, a tag triggers multiple events. If each event tracking has to be located one by one, the workload is relatively large and tedious. Now we introduce a method that can track events in batches.

Suppose there are several locations on the blog that need to be tracked for events. The specific locations are as follows:

ga-data Method(Bulk Event Tracking)

There are four places to do event tracking.

Setup Process

1、Add ga-data attribute

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

ga-data Method(Bulk Event Tracking)

 

Let the colleague of development add the ga-data attribute on it, such as ga-data = “1”. Each location that needs to be tracked needs to be added and assigned a value. The effect after adding is as follows:

ga-data Method(Bulk Event Tracking)

 

2、Setting Variables

Need to set three variables

element

Create a User-Defined Variables Auto-Event Variable and name it element,Variable Type set as Variable , The specific configuration is as follows:

ga-data Method(Bulk Event Tracking)

Custom JavaScript

Create a Custom JavaScript, then copy the following code into it and name it Get-ga-data:

<span style="font-size: 12pt;">function() {
	var elem = {{element}},
	    attr = "ga-data", // change this to the attribute that you want to get
        result = (elem.getAttribute && elem.getAttribute(attr)) || null;

	if( !result ) {
		var attrs = elem.attributes,
			l = attrs.length;
		for(var i = 0; i < l; i++) {
			if(attrs[i].nodeName === attr)
				result = attrs[i].nodeValue;
                }
	}

	return result;
}</span>

The specific configuration is as follows:

ga-data Method(Bulk Event Tracking)

Lookup Table

Create a lookup table and name it Lookup Table-ga-data:

ga-data Method(Bulk Event Tracking)

 

Input Variable Select Get-ga-data; Input is the ga-data value set previously , It is the value in ga-data = “1”,  and output can be customized for specific locations:

 

ga-data Method(Bulk Event Tracking)

 

2、Setting Triggers

Create a Click-All Elements trigger, select Some Clicks, named as Bulk:

ga-data Method(Bulk Event Tracking)

The range of the trigger condition is the value range in ga-data, which is why the value is used in ga-data. More convenient positioning.

 

3、Setting Tags

Make the following settings:

ga-data Method(Bulk Event Tracking)

4、Preview

ga-data Method(Bulk Event Tracking)

 

On the real time report back to Google Analytics:

ga-data Method(Bulk Event Tracking)

The data was also received.

We done!

 


If you don't understand, You can leave a comment below or email me (haran.huang@ichdata.com).
Tags , ,