Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicating data using multiple Piwik trackers doesn't work (documentation) #11340

Closed
mschmitz89 opened this issue Feb 13, 2017 · 4 comments · Fixed by #11381
Closed

Duplicating data using multiple Piwik trackers doesn't work (documentation) #11340

mschmitz89 opened this issue Feb 13, 2017 · 4 comments · Fixed by #11381
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@mschmitz89
Copy link

mschmitz89 commented Feb 13, 2017

Hey, I'm using latest PIWIK 3.0.1 and want one part of the website being tracked in 2 websites simultaneously.

I followed the way written in the documentation to accomplish this: https://developer.piwik.org/guides/tracking-javascript-guide#multiple-piwik-trackers
The tracking code I'm using:

`<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//piwik.domainxy.de/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', '1']);

	// Include second tracking
    var websiteIdDuplicate = 6;
    _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>
<noscript>
<p><img src="//piwik.domainxy.de/piwik.php?idsite=1" style="border:0;" alt="" /></p>
<p><img src="//piwik.domainxy.de/piwik.php?idsite=6" style="border:0;" alt="" /></p>
</noscript>
<!-- End Piwik Code -->`

But only the first Website gets tracked.

It's the same behaviour in PIWIK 2.16.5.

@mattab
Copy link
Member

mattab commented Feb 20, 2017

Could you send us your website URL where you have put this code?

@mattab mattab changed the title Multiple Piwik trackers doesn't work Duplicating data using multiple Piwik trackers doesn't work Feb 21, 2017
@mattab
Copy link
Member

mattab commented Feb 21, 2017

Thanks for the report, I could reproduce this issue.

The solution is to explicitely set the piwik URL as the second parameter.

So replace _paq.push(['addTracker', piwikUrl = null, websiteIdDuplicate]);

by _paq.push(['addTracker', u+'piwik.php', websiteIdDuplicate]);

I'll fix now the documentation

@mattab mattab self-assigned this Feb 21, 2017
@mattab mattab added the Bug For errors / faults / flaws / inconsistencies etc. label Feb 21, 2017
@mattab mattab added this to the 3.0.2 milestone Feb 21, 2017
mattab added a commit to matomo-org/developer-documentation that referenced this issue Feb 21, 2017
mattab added a commit to matomo-org/developer-documentation that referenced this issue Feb 21, 2017
@mschmitz89
Copy link
Author

Thank you Matt, works perfectly! :)

@tsteur
Copy link
Member

tsteur commented Feb 21, 2017

BTW we could likely make that work by changing order in piwik.js of

var applyFirst = ['addTracker', 'disableCookies', 'setTrackerUrl', 

to

var applyFirst = ['setTrackerUrl', 'addTracker', 'disableCookies',

but haven't tested it

@mattab mattab changed the title Duplicating data using multiple Piwik trackers doesn't work Duplicating data using multiple Piwik trackers doesn't work (documentation) Feb 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
3 participants