- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
This article describes how to sample your tracking calls through Tealium iQ so you can reduce vendor costs and control data bandwidth requirements.
Below are some links to learn more about sampling:
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:
Both options use a simple random sampling technique (versus systematic or stratified).
var sample_rate = 5; //sample rate = 5%
var proceed = (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.
Be sure to adjust the Scope to your intended Tag(s), or all tags, as needed. Save & Publish to commit your changes.
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:
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.
This page variable will store the true/false output from the extension in step 1.
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.
Copyright All Rights Reserved © 2008-2023