- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
01-03-2017 02:01 PM
What's the functional difference between the 'b' 'utag.data' and 'u.data' objects in the Template code?
When I step through one of my templates js code in runtime, the utag.data object that I typically reference for object variables does Not have some data that i'd expect it to... whereas the 'b' object does.
If it helps, this particular scenario i'm seeing is in a mobile single-page app environment.
Also, if it matters, I'm seeing a link/event call happen prior to a pageview call to utag.
Solved! Go to Solution.
01-03-2017 03:47 PM
Here is a high level overview of the Data Layer.
However, it may lack some specifics about what you're looking for so below is a breakdown that hopefully helps:
utag.sender[a].send(d.event, utag.handler.C(d.data));Within the template the event type is referenced as "a", and "b" is that copy of utag.data within the template
u.send = function (a, b) {
When to use one over the other?
This may or may not cover all scenarios, but it basically comes down to scoping requirements. In your scenario for the SPA, you should be referencing "b" because it is specific to the new event, whereas "utag.data" is specific to the page load event.
Hopefully this helps!
Cheers,
-Dan
01-03-2017 08:48 PM
Thanks Dan, that does help. Greatly!
One clarification - the template that this is affecting (unforutnately) has a lot of customization within it, and currently that customization is priarmily using the utag.data object instead of the b. It sounds like switching the customized bits to the 'b' object would be the correct way of doing things (and makes sense with what I'm seeing in stepthrough). Just wanted to makes sure that your scenarios/use-cases apply to template coding as well as extension.
Is there also a nice doc or writeup explaining when and where the extension code gets aggregated on compile depending on how it's scoped? i.e. if itt's scoped to all tags, if its pre-loader, before load rules, after load rules, scoped to 1 tag, to multiple tags, etc? sometimes i've seen the code in the utag.js file, and other times it's been in the template files.(utag.js123, etc)
01-04-2017 08:03 AM
Yes, switch to "b" and that should resolve a majority of the issues. The scenarios/use-cases mentioned will apply to both template code and extensions.
I don't know of any such documentation, but maybe @kathleen_jo does. Though I can tell you that extension scope fully effects where the code is pulled into.
01-04-2017 08:25 AM
Awesome! Thanks Dan. super helpful as usual.
01-08-2017 10:37 PM
05-02-2017 03:18 PM
@dan_george, I'm finding some scenarios where on a breakpoint set during execution of Before Load Rules js code, I have valid value for a data layer variable "pageType".
However, at the same time, when I look at utag.data["pageType"], it shows something different. Then also after I finish that pageload where the valid value call was the last call to tealium - if I look at utag.data then it's still showing the invalid value.
When does the utag.data get updated during execution? Based onyour previous answer, I would have expected it to populate between preloader and before load rules, and then again also when I update it using the 'b' object pointer within the utag.js extensions.
05-02-2017
03:55 PM
- last edited on
05-03-2017
09:17 AM
by
TealiumJustin
Just for clarification purposes, if you search utag.js for utag.loader.initdata, that is the exact function that declares utag.data in the first place based off of utag_data. This is called, as you assume, after Preloader extensions are ran but prior to Before Load Rule type extensions. For the most part utag_data and utag.data should mimic each other from this point forward.
That being said, I'm a bit stumped. When your Before Load Rule breakpoint hits, everything that has been added to the data layer is of global scope to Tealium so if you update utag_data it will update utag.data, and visa versa.
My initial thought is that there is a utag.link or utag.view that is being triggered on the page causing this. For example, let's say you set utag_data.pageType="home" on page load. But you also trigger a utag.view via jQuery onHandler extension for when some dynamic content loads, and the extension uses custom code to pass utag.data.pageType="dynamicContent". Within your breakpoint you may see this mismatch, though post page load, utag_data.pageType and utag.data.pageType should still be equal.
Hmm, @TealiumJustin any ideas?
This is one of those scenarios where having access to a URL including steps to reproduce the issue is the only clear way to provide exact guidance on the issue, otherwise we are making assumptions. :) If that information cannot be provided here then I recommend submitting a support ticket.
Cheers,
-Dan
05-03-2017 09:30 AM
Thanks @dan_george! We found the issue with some more debugging. We had some custom js that was persisting the values unexpectedly. Thanks however for the additonal thorough details on the data layer movements though!
Copyright All Rights Reserved © 2008-2023