Two tracking IDs at once?

Hi,

I have three domains - e.g. domain1.com, domain2.com, and domain3.com. I want to track each one separately, but also have a unified account showing data from all three.

So far, I have a standard tracking code on each domain, working properly, as follows:


    <script type="text/javascript">
      var _paq = _paq || [];
      _paq.push(["trackPageView"]);
      _paq.push(["enableLinkTracking"]);

      (function() {
        var u=(("https:" == document.location.protocol) ? "https" : "http") + "://stats.domain.com/";
        _paq.push(["setTrackerUrl", u+"piwik.php"]);
        _paq.push(["setSiteId", "1"]); // With 1 being 'domain1.com', for example
        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);
      })();
    </script>

What do I need to add so that I can track two sites (i.e. the specific site, and the aggregated site) at once? I tried adding something like:


      var _paq_all = _paq_all || [];
      _paq_all.push(["trackPageView"]);
      _paq_all.push(["enableLinkTracking"]);

and inside the function…


        _paq_all.push(["setTrackerUrl", u+"piwik.php"]);
        _paq_all.push(["setSiteId", "5"]); // With 5 being 'all domains', for example

… but this didn’t seem to work. Any tips much appreciated!

Thanks,

Matt

See: http://piwik.org/docs/javascript-tracking/#toc-multiple-piwik-trackers

You should use SYNC version (not async)