Tag capping, counting and frequency

Bronze Contributor
Bronze Contributor

Hi, 

 

I am looking for a way to count/measure the number of times a tag has fired for a given user, and subsequently create load rules around, a way of tag firing frequence capping. 

I realise it will require some coding and a Javascript ext. probably, at which I am fairly novice in terms of coding myself. 

Could you please help with providing guidance in doing such tracking? 

/ Jesper

2 REPLIES 2

Tag capping, counting and frequency

Tealium Employee

Hi @jebg 

 

Add one JS extension and scope it to the tag. Add this code snippet:

var tagName = "facebook";

// dont edit bellow
var t = JSON.parse(localStorage.getItem('tagLoadTracking') || "{}");
t[tagName] = (t[tagName] || 0) + 1;
localStorage.setItem('tagLoadTracking', JSON.stringify(t));

Repeat for all tags that you want to keep load tracking.

Change the "tagName" to the appropriate one on each extension. (make sure to use a full word, without spaces and such)

The result will be a local object like so:

2020-05-06_11h15_57.png

From here you can pick something like so to create your load rules logic:

var t = JSON.parse(localStorage.getItem('tagLoadTracking') || "{}");

// create a variable that would allow to fire a tag (extension before load rules)
if(t["adobe"] > 5) {
    b.is_adobe_fired_more_that_5_times = true;
}

Hope this helps

Thanks

 

 

Tag capping, counting and frequency

Bronze Contributor
Bronze Contributor

It does some of the job, but would this "count" not be for all loads? I need to count for a specific user. My line of thought was creating some event every time a tag loaded, then doing a timeline or tally or number attribute in AS, either on Visit or Visitor, depending on Use Case, so I could keep tabs on how many time that specific user was "exposed" to a tag. 

Public