If I redirect to an internal page and then do a timed redirect to the iTunes link, how long will it take for the tracking script to track a hit?
There is a better way of doing this than just waiting for a specific amount of time. Google Analytics event tracking supports a "call back" function that you can pass it. You can create such a call back function that changes the URL and it executes as soon as Google Analytics tracking has finished.
I implemented something like this and use the following function which wraps around Universal Analytics:
function logeventga(category, action, label, value, callback, nonAction){
var event = {
'eventCategory': category,
'eventAction': action
};
if (label) event['eventLabel'] = label;
if (value) event['eventValue'] = value;
if (callback) event['hitCallback'] = callback;
if (nonAction) event['nonInteraction'] = 1;
if (typeof ga == 'function' && ga.hasOwnProperty('loaded') && ga.loaded === true) {
ga('send', 'event', event);
} else if (callback) {
callback.call();
}
}
This method checks to see if Google Analytics is loaded so that the callback function gets executed even if the analytics js gets blocked by AdBlock.
You could use it something like this called from the onload event:
logeventga('redirect', 'redirect', href, null, function(){
window.location.href = href;
});
You would probably also want to set your Google Analytics snippet NOT to track a "pageview" on this particular page.
The disadvantage of using this approach would be that the redirect won't work for non-JavaScript enabled browsers and web crawlers. To make it work better for those browsers that would do a meta refresh after a few seconds if the JavaScript didn't execute for some reason. Google Analytics tracking usually executes within a few hundred milliseconds.
<meta http-equiv="refresh" content="5; url=http://example.com/">