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

PiwikTracker PHP client: when bulk tracking, Custom variables are now reset after each request #5291

Closed
anonymous-matomo-user opened this issue Jun 3, 2014 · 7 comments
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Milestone

Comments

@anonymous-matomo-user
Copy link

When doing bulk tracking through the PHP Tracking API (using PiwikTracker.php) I noticed that as soon as I set a custom variable for a visit, this custom variable "bleeds over" to all other visits which are processed afterwards in the same bulk request.

As far as I can tell, when calling "$t->doTrackPageView", "$t->doTrackEcommerceOrder" or any other function which finalizes the processing of one page, all custom variables data should be reset. This seems to work for scope "page", but for scope "visit" all other page requests inherit the custom variables which were set until now.

This can easily be reproduced - just set a custom variable with scope "visit" in the first request being processed when using "$t->enableBulkTracking()" and the PiwikTracker class, and then process completely different visits (with different IPs, visitor IDs, etc.) without setting the custom variable again. Then call "$t->doBulkTrack()" - the custom variable will be shown in any visits which were processed.

@mattab
Copy link
Member

mattab commented Jun 5, 2014

In dbd8960: Fixes #5291 Reset the object properties, when issuing a bulk request
to avoid leaking values from one visitor request to the next (who could be completely different visitor)

@mattab
Copy link
Member

mattab commented Jun 5, 2014

In 774431d: Refs #5291 Revert commit because it broke too many tests

@mattab
Copy link
Member

mattab commented Jun 5, 2014

In 0ed11b1: Fixes #5291 Adding new method clearCustomVariables()
-> please use this method to make sure your custom variables are reset

Thanks for the report!

@anonymous-matomo-user
Copy link
Author

Thanks for the fast fix :-)

Wouldn't it be possible to call clearCustomVariables automatically after each page is processed? This would only be necessary if bulk tracking is enabled, and I think it would always make sense - bulk tracking is by definition used to import many page views at once, and usually this entails different visits and users.

I just think it would avoid a possible pitfall for anybody implementing bulk tracking, then adding custom variables at some stage, but forgetting to also clear the custom variables for each page view.

@mattab
Copy link
Member

mattab commented Jun 7, 2014

In 5e65cfb: Refs #5291 adding call to clearCustomVariables()
Let's see if some test will fail as a result.

@mattab
Copy link
Member

mattab commented Jun 7, 2014

In 36560f6: Refs #5291 Updating test files after custom variables are cleared between each request

@iquito thanks for the tip, it is a better solution!

@mattab
Copy link
Member

mattab commented Jun 8, 2014

In d050f1a: Refs #5291 Also clearing user agent and accept-language

@anonymous-matomo-user anonymous-matomo-user added this to the 2.4.0 - Piwik 2.4.0 milestone Jul 8, 2014
This issue was closed.
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. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Projects
None yet
Development

No branches or pull requests

2 participants