Multiple Trackers (Synchronous)



I have a site that needs multiple trackers (from different Piwik installs)…unfortunately I am running Piwik 1.12 so I must use the synchronous tracker in order to do this (or so I’ve read) However I am having trouble finding any documentation on how to do this. I (through much searching) have found the synchronous tracking code snippet, but I dont know what/how to modify this so I can implement multiple trackers, is it simply having one synchronous and the other asynchronous or do I need both to be synchronous and change how the trackers are named?

Any guidance would be greatly appreciated. Thanks.

(Matthieu Aubry) #2

Hi there,

please see: JavaScript Tracking Client: Integrate - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3


So my code would look something like this (because I cant use piwikAsyncInit)?

 <script type="text/javascript">
        var pkBaseURL = (("https:" == document.location.protocol) ? "" : "");
        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("http://URL_1/piwik.php", 1);
            var piwik2 = Piwik.getTracker("http://URL_2/piwik.php", 4);
        } catch( err ) {}

My concern is loading piwik.js, will there be conflict loading this from two separate servers? (I doubt they are running the exact same platform version)…also how should I handle loading piwik.js from from two domains, the above only addresses two domains for piwik.php.



Okay It looks like the other tracker changed the name of piwik.php and piwik.js and also customized the Piwik object name in piwik.js…which is good news, except I think I still need to use the synchronous code since they are still using paq despite all their changes. Any way around this or am I stuck with the synchronous code?