diff options
author | mattab <matthieu.aubry@gmail.com> | 2014-05-09 12:11:47 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2014-05-09 12:11:47 +0400 |
commit | 1600e344012362cd19c1791fe89ecc85256319e4 (patch) | |
tree | f64bbbbdfba08703e28295a54de795da4ed72f34 /libs/PiwikTracker | |
parent | 7e617f1ba0f8e561091dc7f673f28868dc02d331 (diff) |
Fixes #5123 PHP Tracker, added new method setForceNewVisit() to force creation of a new visit + with test
Close https://github.com/piwik/piwik/pull/218
Diffstat (limited to 'libs/PiwikTracker')
-rw-r--r-- | libs/PiwikTracker/PiwikTracker.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libs/PiwikTracker/PiwikTracker.php b/libs/PiwikTracker/PiwikTracker.php index a62feb7a8b..95c10bf676 100644 --- a/libs/PiwikTracker/PiwikTracker.php +++ b/libs/PiwikTracker/PiwikTracker.php @@ -170,6 +170,7 @@ class PiwikTracker $this->eventCustomVar = false; $this->customData = false; $this->forcedDatetime = false; + $this->forcedNewVisit = false; $this->token_auth = false; $this->attributionInfo = false; $this->ecommerceLastOrderTimestamp = false; @@ -903,6 +904,21 @@ class PiwikTracker } /** + * Forces Piwik to create a new visit for the tracking request. + * + * By default, Piwik will create a new visit if the last request by this user was more than 30 minutes ago. + * If you call setForceNewVisit() before calling doTrack*, then a new visit will be created for this request. + * + * Allowed only for Super User, must be used along with setTokenAuth() + * + * @see setTokenAuth() + */ + public function setForceNewVisit() + { + $this->forcedNewVisit = true; + } + + /** * Overrides IP address * * Allowed only for Super User, must be used along with setTokenAuth() @@ -1274,6 +1290,7 @@ class PiwikTracker (!empty($this->ip) ? '&cip=' . $this->ip : '') . (!empty($this->forcedVisitorId) ? '&cid=' . $this->forcedVisitorId : '&_id=' . $this->getVisitorId()) . (!empty($this->forcedDatetime) ? '&cdt=' . urlencode($this->forcedDatetime) : '') . + (!empty($this->forcedNewVisit) ? '&new_visit=1' : '') . ((!empty($this->token_auth) && !$this->doBulkRequests) ? '&token_auth=' . urlencode($this->token_auth) : '') . // Values collected from cookie @@ -1324,6 +1341,9 @@ class PiwikTracker $this->pageCustomVar = false; $this->eventCustomVar = false; + // force new visit only once, user must call again setForceNewVisit() + $this->forcedNewVisit = false; + return $url; } |