Piwik javascript code

tell me please how to insert the code piwik in a separate javascript file on html-site?

create a file called something like “tracking.js”, and then you would add in the HTML document (in the head):

thnx.
what should be in the javascript file?

In tracking.js add your piwik tracking code tag. example below, make sure to change as appropriate to your local install:


var pkBaseURL = (("https:" == document.location.protocol) ? "https://localhost/piwik/" : "http://localhost/piwik/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}

With this option, chrome said “unexpected token on line 3”
Legenda, does it work in your server?