import_logs.py not recognizing returning visitors

Hello,

Visits are imported into Piwik, so that runs fine. But the problem I’m running into is that returning visitors are not recognized as returning, but marked as new a visitor. See attachment, the top and third visitor are using same IP, browser and OS. So the top visitor should be marked as a “returning visitor”? But its not :S

I’m using a fresh installation of Piwik 1.8.4, and using the apache log import (no javascript tracker).
I use logrotation on the apache access log. After rotation, the following command is used to import the visitis into piwik:


/path/misc/log-analytics/import_logs.py --url=http://piwik.example.org /var/log/apache2/other_vhosts_access.log.1  --enable-http-errors --add-sites-new-hosts  --output=/var/log/piwik.log

I’ve tried to increase visit_standard_length


[Tracker]
visit_standard_length = 86400

but then ‘returning’ visitors are not reconized as returning visit, but just as one very long visit…

Why are returning visits not marked as so?

I investigated the code, indeed it is not easily possible to change for what you ask for.

However we can maybe add a new config setting for increasing window looking back to increase returning visitors accuracy.

Can you try the following patch? If it works we’ll want to add the 86400 as a config parameter.


--- core/Tracker/Visit.php	(revision 7005)
+++ core/Tracker/Visit.php	(revision )
@@ -990,7 +990,7 @@
 		
 		$bindSql = array();
 		
-		$timeLookBack = date('Y-m-d H:i:s', $this->getCurrentTimestamp() - Piwik_Config::getInstance()->Tracker['visit_standard_length']);
+		$timeLookBack = date('Y-m-d H:i:s', $this->getCurrentTimestamp() - Piwik_Config::getInstance()->Tracker['visit_standard_length'] - 86400 );
 
 		// This setting would be enabled for Intranet websites, to ensure that visitors using all the same computer config, same IP
 		// are not counted as 1 visitor. In this case, we want to enforce and trust the visitor ID from the cookie.

it works :slight_smile: I’ve got returning visitors! thank you very much!

86400 means that if a visitor returns within 24hr it is marked as returning visitor, or else its marked as a new visitor?