This article describes how to sample your tracking calls through Tealium iQ so you can reduce vendor costs and control data bandwidth requirements.

Table of Contents Placeholder

Prerequisites

Below are some links to learn more about sampling:

Sampling Methods

Sampling data can save time, reduce data retention costs and reduce data bandwidth requirements while retaining accuracy if the representative sample size is sufficient.  The below methods cover two options for utilizing sampling in your Tealium deployed website OR native mobile app:

  1. Event-based sampling
  2. Tag-based sampling

Both options use a simple random sampling technique (versus systematic or stratified).

Event-based Sampling

If you have a large number of events firing from an associated tag, you can reduce the total number of those outbound calls by implementing event-based sampling control.  To implement, add a Javascript Extension in the Extensions tab of your Tealium iQ Dashboard.  Place the following code into the extension:

var sample_rate = 5; //sample rate = 5%
var proceed = (Math.random() < (sample_rate/100)) ? "true" : "false";
return proceed;

You can change the "sample_rate" value to any whole number between 0 and 100. Lower rates equal a lower probability a given call will be sent.  

Be sure to adjust the Scope to your intended Tag(s), or all tags, as needed. Save & Publish to commit your changes.

Tag-Based Sampling

Instead of limiting the number of total events from any given tag, the same sampling technique can be applied to the loading of tags.  This is more complicated to set up but has the advantage of reducing some of the overhead of loading a tag while maintaining statistical relevance.

Setup requires modifying 3 components in your Tealium iQ Tag Management Dashboard:

  1. Add an Extension
  2. Add a Data Object
  3. Add a Load Rule

Add an Extension (Step 1)

In your Extensions tab, add a new Javascript Extension which can be found under the Advanced sub tab.  Call it something like "Sampling Rate Controller - Tag" and enter the following code:

var sample_rate = 5; //sample rate: 5% 
b.isSample = (Math.random() < (sample_rate/100)) ? "true" : "false";

You can change the "sample_rate" value to any whole number between 0 and 100. Lower rates equal a lower probability a given call will be sent.  Set the scope to All Tags.

  This extension randomly determines if the targeted tags will be loaded by the Load Rule in step 3.

Add a Data Object (Step 2)

In your Data Layer tab, add a new Javascript Page Variable called "isSample".

 This page variable will store the true/false output from the extension in step 1.

Add a Load Rule (Step 3)

Finally, we're going to use a Load Rule to either permit or deny the loading of tags. These are done per session, so whenever a user reloads a webpage or restarts an app, this logic will do a fresh run and determination if the target tags are to be loaded.

In your Load Rules tab, add a new Load Rule. Call it something like "Sample Rate", set the first operand (variable object) to "isSimple(js_page).  Change the operator to "equals (ignore case)" and then set the last operand (target value) to "true". 

Click Apply then save/publish to commit your changes.

Version history
Last update:
‎05-13-2019 01:54 PM
Updated by:
Public