Clearing utag_data in Ajax/"single-page application"

patrick_heavey
Rookie Contributor
patrick_heavey
We have a "single-page application" site that uses Ajax-ish functionality (Ember, I believe) to load screens without server calls. As the screens are loaded, we're firing utag.view with the appropriate utag_data name/value pairs. However, in some cases, a variable from a previous screen is incorrectly set on a subsequent page. The developer is (lazily, I think) asking if there is a Tealium-specific method to clear the variables each time. Any help is appreciated.
3 REPLIES 3

Clearing utag_data in Ajax/"single-page application"

son_hoang
Employee Emeritus
son_hoang
Hi Patrick, If I'm understanding your use-case correctly, I think this is a fair question to ask. What I would recommend trying is rather than do a call to utag.view() or utag.link() alone, do this instead: //note the first line is referencing utag.data, not utag_data utag.data = {}; utag.view ( { name : "data1" } ); Where the value being passed to utag.view() directly are all the values you'd like to use, rather than using utag_data for subsequent calls. This means that if you do want to use a pre-existing value, you'd need to alter this approach. There are some other minor caveats we'd be happy to work through with this if so if you'd like assistance, please contact your AM if you'd need more detailed assistance with this.

Clearing utag_data in Ajax/"single-page application"

patrick_heavey
Rookie Contributor
patrick_heavey
Thanks. To clarify, we are using the method of utag.view ( { name : "data1" } ); but name/value pairs populated previously but not overwritten are being set. In simple terms, does setting utag.data = {}; before the utag.view call "clear" the existing name/value pairs?
Highlighted

Clearing utag_data in Ajax/"single-page application"

son_hoang
Employee Emeritus
son_hoang
Yep, it clears them out.