I had an interesting bug combining InstantClick with Clicky.com (a GA stats tracking alternative).
Clicky dynamically adds a JS file to the header so it's asynchronous. It does the same every few minutes to poll and indicate someone's still on the page.
When used with InstantClick, the first tracking request worked fine. But when I clicked - the first AND second Clicky tracking request were sent. Another click meant 3 new requests were sent.
It puzzled me for a minute, before I realized. Clicky's JS didn't have InstantClicks' data-no-instant attribute, so all previous tracking scripts were being re-loaded with every click.
The fix is to push the tracking requests to Clicky manually via InstantClick's on change callback. Then I used JQuery to add the data-no-instant attr to all the clicky script tags in the head:
InstantClick.on('change', function() {
clicky.log(location.pathname+location.search, document.title, 'pageview');
// now stop any clicky scripts from being re-requested each time the page is insta-reloaded, to stop wasted tracking requests
jQuery("head script[src*='clicky.com']:not([data-no-instant])").attr('data-no-instant', true);
});
The same might happen with Google Analytics if you're using it asynchronously, but I've not tried that.
Hope this helps someone if they see the same weirdness.
Clicky dynamically adds a JS file to the header so it's asynchronous. It does the same every few minutes to poll and indicate someone's still on the page.
When used with InstantClick, the first tracking request worked fine. But when I clicked - the first AND second Clicky tracking request were sent. Another click meant 3 new requests were sent.
It puzzled me for a minute, before I realized. Clicky's JS didn't have InstantClicks' data-no-instant attribute, so all previous tracking scripts were being re-loaded with every click.
The fix is to push the tracking requests to Clicky manually via InstantClick's on change callback. Then I used JQuery to add the data-no-instant attr to all the clicky script tags in the head:
The same might happen with Google Analytics if you're using it asynchronously, but I've not tried that.Hope this helps someone if they see the same weirdness.