- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
As we all know, although the functionality of Load Rules is similar to Conditions, we can't manage extensions using Load Rules or use those Load Rules to replace Extension Conditions.
Load Rules are always in the same location in the UI and can be applied more than once which makes them easy to maintain. They also have the bonus ability to manage timeframes as conditions as well.
We often have the problem of needing to maintain multiple extensions with the same Conditions which could be leveraged by a Load Rule instead.
Here is my take on how we can take advantage of Load Rules within Extensions, and perhaps simplify some implementation and maintenance.
The first method generates a copy of the load rules and re-evaluates them on each event. It works both before and after Load Rules.
The second works only after Load Rules and does not re-evaluate the load rules on each event.
These extensions will have to sit as first 2 extensions before any of the extensions that take advantage of this logic.
This method involved re-evaluating the load rules at each event.
The data is stored in utag object under lr_eval.
Create a new variable for each of the Load Rules you want to reference.
To keep it simple, let's say we are working with Load Rule UID 1 which checks if Visitor Known badge (5885) is assigned.
We can call it loadrule_id1.
You could also give it a more descriptive name in the Alias: Load Rule - Visitor Badge Assigned.
Scope to Before Load Rules
var key; utag.lr_eval = {};
// Make copy of load rule object and default to false for (key in utag.loader.GV(utag.cond)) { utag.lr_eval[key] = false; }
// Update lr_eval values with load rule conditions
utag.loader.loadrules(b, utag.lr_eval);
// Add the load rules evals to the data layer
for (key in utag.lr_eval) { var val = utag.lr_eval[key];
b["loadrule_id" + key] = (val == 1 || val == true || val == 4) ? "true" : "false"; }
Create a Set Data extension.
Title: Load Rules as Conditions
Scope: All Tags Before Load Rules
Assign values for each load rule you wish to use in the Set Data extension to the value from the utag.lr_eval object. The value returned will usually be 1/true or 0/false.
For matching ALL:
utag.lr_eval[1] && utag.lr_eval[2]
For matching ANY
utag.lr_eval[1] || utag.lr_eval[2]
You can also take advantage of multiple load rules using AND/OR/NOT conditions (&&, ||, !).
(utag.lr_eval[1] && utag.lr_eval[2]) || (utag.lr_eval[3] && !utag.lr_eval[4])
Add a new Tealium Custom Container and remove everything inside the template. We don't need the tag to fire, but we do need the Load Rule to be associated with a tag for it to be evaluated.
Add each of the load rules to the tag, and publish to all environments.
In the conditions, select loadrule_id# and check if it equals true or false
Create a new variable for each of the Load Rules you want to reference.
To keep it simple, let's say we are working with Load Rule UID 1 which checks if Visitor Known badge (5885) is assigned.
We can call it loadrule_id1
You could also give it a more descriptive name in the Alias: Load Rule - Visitor Badge assigned
Create a Set Data extension.
Title Load Rules as Conditions
Scope: All Tags After Load Rules
Assign values for each load rule you wish to use in the Set Data extension to the value from the utag.cond object. The value returned will usually be 1/true or 0/false.
For matching ALL:
utag.lr_eval[1] && utag.lr_eval[2]
For matching ANY
utag.lr_eval[1] || utag.lr_eval[2]
You can also take advantage of multiple load rules using AND/OR/NOT conditions (&&, ||, !).
(utag.lr_eval[1] && utag.lr_eval[2]) || (utag.lr_eval[3] && !utag.lr_eval[4])
We will use this to assign all the Load Rule values as a string of "true" or "false" for consistency.
for (var key in b) {
if (key.indexOf("loadrule_id") > -1) {
var val = b[key];
// Set to "true" if 1 or true or 4 (bundled)
b[key] = (val == 1 || val == true || val == 4) ? "true" : "false";
}
}
Add a new Tealium Custom Container and remove everything inside the template. We don't need the tag to fire, but we do need the Load Rule to be associated with a tag for it to be evaluated.
Add each of the load rules to the tag, and publish to all environments.
In the conditions, select loadrule_id# and check if it equals true or false.
That is it. Hope you get lots of use out of it! Please share your feedback in the comments.
Copyright All Rights Reserved © 2008-2023