Tracking Code in 2nd Site in central JS file does not fire HTTP GET to piwik url


#1

var _paq = _paq || [];
    (function(){ var u=(("https:" == document.location.protocol) ? "https://myurl/" : "http://myurl/");
    _paq.push(['setSiteId', 2]);
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['trackPageView']);
    _paq.push(['enableLinkTracking']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.src=u+'piwik.js';
    s.parentNode.insertBefore(g,s); })();

I have above code in a JavaScript File of mine which gets fired before the body closing tag. This is on my 2nd domain. Piwik runs on my first Domain. I configured the site etc in Piwik. However the tracking code (js file) gets pulled; i see it in Firebug, although no HTTP GET to “myurl” gets fired.

However Firing this code from directly my HTML page works:


var _paq = _paq || [];
	  _paq.push(['trackPageView']);
	  _paq.push(['enableLinkTracking']);
	  (function() {
	var u=(("https:" == document.location.protocol) ? "https" : "http") + "://analytics.mySite.com//";
	_paq.push(['setTrackerUrl', u+'piwik.php']);
	_paq.push(['setSiteId', 2]);
	var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
	g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
	  })();

Where do I go wrong?