I realize this may be a little late, but I was searching through forrums trying to do the same thing recently, and was getting nowhere. There seems to be a lot of people out there that want to do this, but not a lot of solutions. I finally came up with my own solution. So for anyone who needs it this is what I did.
take your tracking code simaler to the following
create two javascript files. I called mine piwik.js, and piwik_load.js
in piwik_load.js I put
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + “piwik.php”, 1);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
I then put the following lines in each of my web pages I want to track
Everything is tracking great. I added a few custom variables to piwik_load.js works like a charm.
So bassicly since there are two script blocks in the javascript code you turn each script block into its own javascript file embed the two files in your page with the noscript line at the end of the file, and then if you want to create custom variables create them in the second javascript file