Help with tracking a subdomain

Hi,
I’ve thoroughly read the documentation and while I understand the general idea behind subdomain tracking, I’m not 100% if I got everthing right. So I just need a little bit of help…

Say I have the domain mydomain.com (that I have been tracking for a while) and now I want to track a ministe on sub1.mydomain.com

So I added the sub1.mydomain.com as a new site - that now has the ID 2.

the default code is:

try {
var piwikTracker = Piwik.getTracker(pkBaseURL + “piwik.php”, 1);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}

So what I understand I need to be doing is adding the follwing code on the footer of the subdomain only:

try {
var piwikTracker2 = Piwik.getTracker(pkBaseURL + “piwik.php”, 2);
piwikTracker2.setDomains(’*.mydomain.com’);
piwikTracker2.trackPageView();
piwikTracker2.enableLinkTracking();
} catch( err ) {}

Did I get it right?

Looks good