utag.sync.js & Single Page Apps

Anonymous
Anonymous

Sync vs Async makes perfect sense in the world of multipage sites, but how does it play out in a Single Page App (ajax type stuff) site?

 

Can I reload utag.sync.js during each view of the single page app? Or am I better rigging up something using the traditional utag.js?

2 REPLIES 2

utag.sync.js & Single Page Apps

Tealium Employee

Generally speaking, we recommend using the utag.view() and utag.link() functions for anything to do with AJAX content (https://community.tealiumiq.com/t5/Tealium-iQ/AJAX-Tracking-in-Tealium/ta-p/14034).

The utag.sync.js file is meant to be a container for synchronous code, but it's not our best practice as loading resources synchronously brings the risk of page load failure. However, if you have something specific you're trying to accomplish, I'd recommend contacting your Tealium account manager.

Thannks,

Seth

utag.sync.js & Single Page Apps

Moderator
Moderator

Additionally, you most certainly wouldn't want to reload utag.sync.js, because it is likely to contain document.write statements, which would be catastrophic for a single page AJAX app - the page would most likely be wiped out completely by the document.write calls. utag.sync.js should only be implemented once per page, and in the head only. (I'm assuming this is a true single page app with no "reload" between page views).

 

Hope this helps.

Check out our new Swift integration library for iOS, macOS, tvOS and watchOS: https://github.com/Tealium/tealium-swift with updated
documentation https://community.tealiumiq.com/t5/Swift/tkb-p/swift.
Public