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

Is it possible to send events to two different SiteIds? #11855

Closed
lipis opened this issue Jul 10, 2017 · 4 comments
Closed

Is it possible to send events to two different SiteIds? #11855

lipis opened this issue Jul 10, 2017 · 4 comments
Labels
answered For when a question was asked and we referred to forum or answered it.

Comments

@lipis
Copy link
Contributor

lipis commented Jul 10, 2017

We want to send different events from the same projects but into two different websites..

Will it be OK to setSiteId every time we send an event or there is a better approach to this?

_paq.push(['setSiteId', 1]);
_paq.push(['trackEvent', 'foo', 'bar']);
@RMastop
Copy link
Contributor

RMastop commented Jul 10, 2017

Hi @lipis,

It's best to use addTracker:
It depends on what version of Piwik you use how it is implemented, please find documentation on the following pages:
Piwik 2.x:
https://developer.piwik.org/2.x/guides/tracking-javascript-guide#multiple-piwik-trackers
Piwik 3.x
https://developer.piwik.org/guides/tracking-javascript-guide#multiple-piwik-trackers

Regards,
Richard

@lipis
Copy link
Contributor Author

lipis commented Jul 10, 2017

This is duplicating.. (I guess I had to be more clear). I want to send to a different website depending on the kind of event.

Some events will go to ID: 1 and some will go to ID: 2

@RMastop
Copy link
Contributor

RMastop commented Jul 10, 2017

Ah OK,
A new use case ;)

The problem with your solution, could be that other tracking requests, the ones that will be tracked after the
_paq.push(['trackEvent',`` 'foo', 'bar']);
will end up in the wrong ID.

Make sure you reset
setSiteId
to the default ID after the tracked event.

@lipis
Copy link
Contributor Author

lipis commented Jul 10, 2017

Yes, that's our plan.. thank you @RMastop

@lipis lipis closed this as completed Jul 10, 2017
@mattab mattab added the answered For when a question was asked and we referred to forum or answered it. label Jul 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

3 participants