From 0ed11b178860844b97b967f6cfa1ffd12ab2eaab Mon Sep 17 00:00:00 2001 From: mattab <matthieu.aubry@gmail.com> Date: Thu, 5 Jun 2014 15:03:03 +1200 Subject: [PATCH] Fixes #5291 Adding new method clearCustomVariables() -> please use this method to make sure your custom variables are reset Thanks for the report! --- libs/PiwikTracker/PiwikTracker.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/libs/PiwikTracker/PiwikTracker.php b/libs/PiwikTracker/PiwikTracker.php index 9c2e1379a4..e9a5429b9a 100644 --- a/libs/PiwikTracker/PiwikTracker.php +++ b/libs/PiwikTracker/PiwikTracker.php @@ -360,6 +360,20 @@ class PiwikTracker return $cookieDecoded[$id]; } + /** + * Clears any Custom Variable that may be have been set. + * + * This can be useful when you have enabled bulk requests, + * and you wish to clear Custom Variables of 'visit' scope. + */ + public function clearCustomVariables() + { + $this->visitorCustomVar = false; + $this->pageCustomVar = false; + $this->eventCustomVar = false; + } + + /** * Sets the current visitor ID to a random new one. */ @@ -465,8 +479,8 @@ class PiwikTracker * Enables the bulk request feature. When used, each tracking action is stored until the * doBulkTrack method is called. This method will send all tracking data at once. * - * Note: when you enable bulk tracking, all the properties of this object will be reset - * after each request is sent (ie. datetimes, settings, visitor id, etc. will be initialized to "false"). + * Note: when you enable bulk tracking, consider calling clearCustomVariables() before setting other + * attributes to your visitors and requests to track. */ public function enableBulkTracking() { @@ -1340,6 +1354,8 @@ class PiwikTracker // DEBUG $this->DEBUG_APPEND_URL; + + // Reset page level custom variables after this page view $this->pageCustomVar = false; $this->eventCustomVar = false; -- GitLab