Skip to content

Commit

Permalink
Fixes #4248 this should help with making segments visitCount and days…
Browse files Browse the repository at this point in the history
…SinceLastVisit more accurate!
  • Loading branch information
mattab committed Oct 28, 2013
1 parent b08354a commit fe4ee5d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 11 additions & 4 deletions js/piwik.js
Expand Up @@ -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] = "";
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions piwik.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fe4ee5d

Please sign in to comment.