Joined April 2013
·
Achievements
50 Karma
0 Total ProTip Views
Forked 50
Have a project with a thriving community of users that's been forked at least 50 times
Lemmings 100
Write something great enough to have at least 100 watchers of the project
Forked 20
Have an established project that's been forked at least 20 times
Forked
Have a project valued enough to be forked by someone else
Charity
Fork and commit to someone's open source project in need
I faced this same problem (activations not reliably being recorded), but with a different analytics platform.
I ended up writing a promise-based wrapper around the tracking method. The promise resolves when the tracker image finishes loading.
Used sparingly, this solution provides a synchronous hook into the analytics-tracking workflow and eliminates the unreliable use of setTimeout().
(I also wrote a custom pub/sub implementation that detects when promises are used by subscribers in order to conditionally provide promises on all .publish() calls. This means any subscriber can transparently inject dependencies into the pub/sub lifecycle on an as-needed, even ad-hoc, basis. All analytics tracking is abstracted using events. So, if we want to redirect, but only after all of an event's subscribers have finished responding to the event, all we have to do is wrap the redirect in the event's .done() method.)