diTii.com Digital News Hub

Sign up with your email address to be the first to know about latest news and more.

I agree to have my personal information transfered to MailChimp (more information)


Yahoo! Web Analytics: Dynamic Tracking Code Loading in HTTPS or HTTP

Monitoring websites with secure pages requires the use of two different sets of Yahoo Web Analytics tracking code, one for secure pages and the other for non-secure pages. The drawback to this’s that you’re left with inconsistent tracking code across the site and care must be exercised to ensure that the correct tracking code is being used in the right place.

Yahoo! Analytics blog posted a nifty solution “integrate a discriminator according to the protocol used on the page to load only the code necessary for that page.” “Additionally, we must know when JavaScript is loaded and execute the tracking code without causing execution errors,” stated Yahoo!

The solution is taken in 4 steps:

  1. TrackPage. Page tracking function.
  2. Dynamic loading of JavaScript. Load appropriate JS source from YWA.
  3. Execute TrackPage. Once the JS is loaded, execute TrackPage.
  4. NoScript. Element for non-JavaScript enabled tracking.

Here’s the complete code:



Share This Story, Choose Your Platform!

Get Latest News

Subscribe to Digital News Hub

Get our daily newsletter about the latest news in the industry.
First Name
Last Name
Email address
Secure and Spam free...