@PatrickVdC wrote:
I recently installed Piwik 3.0.1 to track a large(ish) organization's intranet pages. I need to track metrics for the different teams' pages in different websites (all on the same Piwik instance), so I can assign users per team to view their team's data. I also need to be able to see all the data in a "global" website, so I can track usage overall.
I have tried multiple approaches, but can't get it to work. Here's what I tried.
Multiple trackers on a single page
Ideally (with the CMS we use) I'd like to use 2 different trackers: one "specific" tracker for the team (which is at the top of all their pages), and one "global" tracker (which is at the bottom of all pages). I'm using the Javascript tracker as it is generated by Piwik.
While both trackers seem to track Visits, Visitors, Page Views, Devices, Software, and so on, Downloads and Outlinks only get tracked through the bottom (i.e., last) tracker. So that's not a valid solution.
One other possible solution I thought could work was to increase the delay for the link tracking (which would impact both Downloads and Outlinks). I tried by adding the delay as follows:
var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['setLinkTrackingTimer', 750]); // increase to 750 milliseconds _paq.push(['enableLinkTracking']); (function() { ... })();
That did not work though.
Single tracker pushing data to 2 sites
I then tried configuring a single tracker to push the data into two sites (as described here). This is the code I used:
<script type="text/javascript"> var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u = "//my.server.com/piwik/"; _paq.push(['setTrackerUrl', u + 'piwik.php']); _paq.push(['setSiteId', '24']); var websiteIdDuplicate = 25; _paq.push(['addTracker', piwikUrl = null, websiteIdDuplicate]); var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0]; g.type = 'text/javascript'; g.async = true; g.defer = true; g.src = u + 'piwik.js'; s.parentNode.insertBefore(g, s); })(); </script>
When I add this code to a page, all the metrics get tracked into the first website (SiteId 24), but no data at all is tracked in the 2nd one (SiteID 25). So in a way this is worse than the multiple trackers.
Synchronous vs. Asynchronous Trackers
Some research (FAQ, User Guides, Forums) seems to indicate this is because the trackers run asynchronously, and that synchronous trackers should be used. I don't know how to do that though, do I simply need to set:
g.async = false;
and possibly also:
g.defer = false;
Would that be enough?
Also, I'm not entirely sure anymore if synchronous trackers are still supported with 3.x, and what the differences (drawbacks) are to using a synchronous tracker instead of an asynchronous one. If someone could clarify this as well that would be good for my own mental sanity.
My question
So, my "big" question is: how do I correctly setup the tracker(s) so that I can track the metrics in multiple websites? Any help is appreciated, as I've been struggling with this for the better part of 3 days now, and I just can't figure it out.
Posts: 1
Participants: 1