diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-10-28 09:22:19 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-10-28 09:22:26 +0400 |
commit | fe4ee5dd88542796c29dd0a246eeb301f5488b3d (patch) | |
tree | 1852b167d33271e36336b0bd6b6d0a8892f2c4fd /js | |
parent | b08354a4f396109c5d4a36176da87fdb0e87da38 (diff) |
Fixes #4248 this should help with making segments visitCount and daysSinceLastVisit more accurate!
Diffstat (limited to 'js')
-rw-r--r-- | js/piwik.js | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/js/piwik.js b/js/piwik.js index 10da96ea67..88a9f19bfb 100644 --- a/js/piwik.js +++ b/js/piwik.js @@ -1614,7 +1614,6 @@ if (typeof Piwik !== 'object') { visitCount = id[3]; currentVisitTs = id[4]; lastVisitTs = id[5]; - // case migrating from pre-1.5 cookies if (!isDefined(id[6])) { id[6] = ""; @@ -1641,10 +1640,18 @@ if (typeof Piwik !== 'object') { referralUrl = attributionCookie[3]; if (!ses) { - // new session (aka new visit) - visitCount++; + // cookie 'ses' was not found: we consider this the start of a 'session' + + // here we make sure that if 'ses' cookie is deleted few times within the visit + // and so this code path is triggered many times for one visit, + // we only increase visitCount once per Visit window (default 30min) + var visitDuration = configSessionCookieTimeout / 1000; + if (!lastVisitTs + || (nowTs - lastVisitTs) > visitDuration) { + visitCount++; + lastVisitTs = currentVisitTs; + } - lastVisitTs = currentVisitTs; // Detect the campaign information from the current URL // Only if campaign wasn't previously set |