From def6da2ee5deaa600bbaae004c3e3f5db348b61e Mon Sep 17 00:00:00 2001 From: mattab <matthieu.aubry@gmail.com> Date: Mon, 14 Oct 2013 18:32:43 +1300 Subject: [PATCH] Fixes #4217 Load Visitor ID from first party cookie if available --- libs/PiwikTracker/PiwikTracker.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/libs/PiwikTracker/PiwikTracker.php b/libs/PiwikTracker/PiwikTracker.php index 4752abcd1f..1e0ff01c0f 100644 --- a/libs/PiwikTracker/PiwikTracker.php +++ b/libs/PiwikTracker/PiwikTracker.php @@ -716,16 +716,11 @@ class PiwikTracker * * Allowed only for Admin/Super User, must be used along with setTokenAuth(). * - * For example, on your website if you use the Javascript tracker in some pages - * and the PHP tracker in other pages, you can write: - * $v->setVisitorId( $v->getVisitorId() ); - * - * This will set this visitor's ID to the ID found in the 1st party Piwik cookies - * (created earlier by the Javascript tracker). - * - * Alternatively you can set the Visitor ID based on a user attribute, for example the user email: + * You may set the Visitor ID based on a user attribute, for example the user email: * $v->setVisitorId( substr(md5( $userEmail ), 0, 16)); * + * If not set, the visitor ID will be fetched from the 1st party cookie, or will be set to a random UUID. + * * @see setTokenAuth() * @param string $visitorId 16 hexadecimal characters visitor ID, eg. "33c31e01394bdc63" * @throws Exception @@ -1050,7 +1045,7 @@ class PiwikTracker // Only allowed for Super User, token_auth required, (!empty($this->ip) ? '&cip=' . $this->ip : '') . - (!empty($this->forcedVisitorId) ? '&cid=' . $this->forcedVisitorId : '&_id=' . $this->visitorId) . + (!empty($this->forcedVisitorId) ? '&cid=' . $this->forcedVisitorId : '&_id=' . $this->getVisitorId()) . (!empty($this->forcedDatetime) ? '&cdt=' . urlencode($this->forcedDatetime) : '') . ((!empty($this->token_auth) && !$this->doBulkRequests) ? '&token_auth=' . urlencode($this->token_auth) : '') . -- GitLab