i’m trying to implement Woopra custom event data on page load, and i’m using their guidelines
i have tried to push events on page ready but it always gives me that woopratracker is not defined, but however when i try to use it onclick event it works fine, i think that there is a delay in loading woopra libraries, but however i’m calling it’s functions on page ready which means that my call should wait for page ready before it executes!
i have settimeout and called the same function after 1 second, it worked fine, but still not logical, any ideas?? Thank you 🙂
i’m trying to implement Woopra custom event data on page load, and i’m using
Share
You’re right – you’re calling woopraTracker before the page is loaded. The most recent snippet on their site is async which means if you call woopraTracker right after this code, it will likely fail since
wsc.async=truetells the browser to continue without waiting for this script to initialize. If you know what you want to track in advance, put that code into woopraReady.In this example, that’s exactly what they do: http://www.woopra.com/docs/tracking/custom-event-data/. It looks like you already found this doc, but are you placing your code into
woopraReadyand using the localtrackervariable instead of the globalwoopraTracker?woopraReadywill be called once the script is loaded so you won’t run into the issue you’re experiencing.If you have other stuff that tracks events, it can’t hurt to wrap the
woopraTracker.trackEvent()in case the script didn’t load either because the user was really fast or because woopra had an error loading.Instead of calling woopraTracker directly you could define your own wrapper: