How to track the subdomains?

I wan to track one domain with subdomains of it.
I have read here that I should put cookie with domain in javascript

_paq.push(['setSiteId', 1]);
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setCookieDomain', '*']); // Same cookie as:,,, ...
_paq.push(['setDomains', '*']); // Download & Click tracking alias domains

but code my Piwik gives me different from example, without _paq.push. Like this:

var pkBaseURL = (("https:" == document.location.protocol) ? "https://domain/analytics/" : "http://domain/analytics/");
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", 75);

Can somebody help me to add this coockie staff to my code?


JS tracking code changes relatively often.
I recommend you upgrading to the latest version (1.11.1), because JS tracking code now is asynchronous.
In the “settings->tracking code” page you can then generate the latest code and even select “Track visitors across all subdomains of Example Homepage”.
That should be the easiest way, because all is done by piwik automatically.

Piwik Tracking-Code recently switched to asynchronous tracking. This is a one-time change however not not “often”.

Thank you guys a lot