matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.71k stars 2.62k forks source link

create_new_visit_when_campaign_changes = 1 not working #12218

Open eramirezprotec opened 6 years ago

eramirezprotec commented 6 years ago

Hi! In the documentation I can read the following:

"By default Piwik will create a new visit whenever a visitor views your website using a different campaign information from the visitor’s ongoing visit. You can disable this behavior by setting create_new_visit_when_campaign_changes=0 under [Tracker] section in your config/config.ini.php file."

But it is not working for me. When I visit my website using different campaigns, Piwik registers always the same campaign established in the cookie a long time ago. It only changes when the session ends and I visit the website using a different campaign (but it has to be the first visit after the session ends, because if not, the old campaign is set again for the new visit).

Btw, is it the intented behavior to keep the same campaign even when the session ends and after that the user visits the site without any campaign specified in the url?

Thank you very much in advanced.

sgiehl commented 6 years ago

Do you have the Marketing Campaigns Reporting plugin installed?

eramirezprotec commented 6 years ago

Hi, @sgiehl.

No, I don't have the Marketing Campaigns Reporting plugin installed.

eramirezprotec commented 6 years ago

This cookie _pk_ref.xxxxx contains information about the campaign and keyword; if I delete it, everything behaves the way it should (creating a new visit for every new campaign, no matter if one is inside the same session). Is this cookie really necessary?

eramirezprotec commented 6 years ago

For now, we have chosen not to set this cookie (_pk_ref.xxxxx), this way everything behaves as we want to. The problem is when this cookie is set, and this happens when the first visit to the site (I mean, without an active session) ocurres with a campaign (URL?pk_campaign=c1, for example); after this, no matter what you do, all new visits (with or without campaigns) are going to be associated with the campaign set in the previous example. All of this happens because of _pk_ref.xxxxx cookie.

peterbo commented 6 years ago

Came here because of the forum issue https://forum.matomo.org/t/campaign-is-there-a-tracking-timeout-after-user-clicks-one-link/28690/7 - this is reproducible in my instance as well. This is because of https://github.com/matomo-org/matomo/blob/c0d6e951f12a8b0585ffd81d68d48309778afbd4/js/piwik.js#L4267 - if a campaign referrer was obtained from the cookie, the check for (changed) parameters from the url is not run at all. So the cookie campaign information has precedence over the actual campaign info in the url and the parameter "create_new_visit_when_campaign_changes" cannot have any effect (only with cookies disabled or deleted).

MatomoForumNotifications commented 1 year ago

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/issues-with-campaign-handling/48989/1

heurteph-ei commented 1 year ago

@peterbo, @sgiehl Isn't it covered by #19657?

MatomoForumNotifications commented 1 year ago

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/issues-with-campaign-handling/48989/2

sgiehl commented 1 year ago

@heurteph-ei Actually not sure about that. Will keep this issue open, so we maybe have another detailed look when working on #19657