Highlighted

Can I use UDO variable in Load Rules?

Rookie Contributor
I'm not sure this could work or not? But the Tag couldn't be fired as my expectation. Here are my steps to use Load Rules: 1. Create new Data Source as UDO Variable on 'Data Layer' tab Ex. named 'test_data' 2. Create 'Lookup Table' to set value for this variable on 'Extenstions' tab Ex. If pagetype_id is matched, set 'test_data' to "1". Otherwise, not set. 3. Create new Rule to use this variable on 'Load Rules' Ex. If 'test_data' equals "1", firing the Tag 4. Create new Tag to use this Rule on 'Tags' So, my expectation is if I go to that page as defined in step 2 then 'test_data' will be set to "1" and the Tag in step 4 should be fired. This usage makes sense? Please advice.
3 REPLIES 3
Highlighted

Can I use UDO variable in Load Rules?

Tealium Employee

Hey Natpatch, Due to the order of operations, the load rule will not get satisfied in this case because load rules are evaluated before extensions are run.

 

Attached is a link to our order of operations whitepaper for more information: https://community.tealiumiq.com/t5/Getting-Started/utag-js-Order-of-Operation-White-Paper/ta-p/326

 

If you need assistance setting up a use case with a more "advanced" load rule, please get in touch with your account manager and we'll be happy to take a look at that.

Highlighted

Can I use UDO variable in Load Rules?

Rookie Contributor
Hi Gilbert, Thank you for your information.
Highlighted

Can I use UDO variable in Load Rules?

Tealium Employee
Hi Natpatch The Order of Operations does explain why this isn't working for you. However, there are still ways to achieve what you wish. One way is to use an extension scoped to Pre-Loader. As the name suggests, these extensions run before load rules are evaluated. Currently, Tealium iQ only supports JavaScript based Pre-Loader extensions. This is due to be improved soon. However, you can still recycle the lookup extension you already wrote, if you wish. What you can do is to find the code that has been published for your lookup extension. It will be in utag.js if it is an All Tags scoped extension. Otherwise, it may be in the utag specific js file for the tag the extension is scoped to, or in the main utag.js (depends on how your bundling is set up). Anyway, you should be able to find the code by using e.g. Chrome developer tools to search all source code for one of the strings your lookup table is using. Here's what the code will look like (mine is generic) , function(a, b, c, d, e, f, g) { d = b['input_source']; if (typeof d == 'undefined') return; c = [{ 'Match1': 'M1' }, 'Match2': 'M2' }, { 'Match 3': 'M3' }]; var m = false; for (e = 0; e < c.length; e++) { for (f in c[e]) { if (d == f) { b['output_source'] = c[e][f]; m = true } ; } ;if (m) break } ;if (!m) b['output_source'] = 'd'; } Once you've found the code, you will need to modify it slightly. Here's my transformed code (function() { window.utag_data = window.utag_data || {}; var b = window.utag_data; var d = b['input_source']; if (typeof d == 'undefined') return; var c = [{ 'Match1': 'M1' }, { 'Match2': 'M2' }, { 'Match 3': 'M3' }]; var m = false; for (var e = 0; e < c.length; e++) { for (var f in c[e]) { if (d == f) { b['output_source'] = c[e][f]; m = true; } } if (m) break; } if (!m) b['output_source'] = 'd'; })(); That code should now run in a PreLoader extension and do what you wish. You can leave your load rule in place. Mark