var gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");
document.write(unescape(\"%3Cscript src=\'\" + gaJsHost + \"google-anal
@Nikko
One possible reason is because the GA account was created using the old analytics. So you must use the traditional analytics code ga.js (_gaq.push). I found an incompatibility in using the new analytics.js with the traditional GA account in the GA website. The hits won't appear so I was forced to use the traditional ga.js.
Also, you may set a callback function to assure the hits are successfully sent, like below:
//traditional way
_gaq.push(['_set', 'hitCallback', function() {
console.log("%c ga.js finished sending pageview data to analytics %s ", "color:black; background: pink", pageviewUrl);
}]);
//new analytics way
ga('send', 'pageview', {
'page': pageviewUrl,
'hitCallback': function() {
console.log("%c analytics.js done sending data. pageview url = %s ", "color: black, background: pink", pageviewUrl);
}
});
where pageviewUrl = the url of the site
Hope that helps!