Jump to content

Bug with visitors online stats


Recommended Posts

This problem concerns the stats module for online visitors integrated in Prestashop.
When a visitor or a customer comes to my website he is then always considered as online even if is not in the website anymore.
Basically everyone who visit my website will be considered as permanently online!

Does anyone else has noticed this problem?

Thanks !

Link to comment
Share on other sites

The "Visitors online" gets the number of connections that were started within 900 seconds (15 minutes) ago. See the getVisitorsOnline() function in modules/statshome/statshome.php:

private function getVisitorsNow()
{
   return Db::getInstance()->getValue('
   SELECT COUNT(DISTINCT cp.`id_connections`)
   FROM `'._DB_PREFIX_.'connections_page` cp
   WHERE TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900');
}



If someone leaves the website one minute after arriving, they will be considered online for another 14 minutes, but not forever. You can decrease the number 900 to a smaller value if you want a more accurate view of exactly how many people are online at the moment.

  • Like 1
Link to comment
Share on other sites

Thanks for your answer.

The strange thing is that the online customers are considered online for something like the last 24 hours and does not seems to clear anything after 900 seconds. I checked the files it's 900 as you said.
I use the version 1.3.0.1

Link to comment
Share on other sites

  • 4 weeks later...
The "Visitors online" gets the number of connections that were started within 900 seconds (15 minutes) ago. See the getVisitorsOnline() function in modules/statshome/statshome.php:

private function getVisitorsNow()
{
   return Db::getInstance()->getValue('
   SELECT COUNT(DISTINCT cp.`id_connections`)
   FROM `'._DB_PREFIX_.'connections_page` cp
   WHERE TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900');
}



If someone leaves the website one minute after arriving, they will be considered online for another 14 minutes, but not forever. You can decrease the number 900 to a smaller value if you want a more accurate view of exactly how many people are online at the moment.



Thank you for this
Link to comment
Share on other sites

  • 6 months later...

I have also problem with prestashop stats. First problem was, that "visitors for day" was much bigger number than is in G Analytics. Now, problem regrowth and prestashop is showing me hundreds of conection each day even if there is less than hundred of them.

Link to comment
Share on other sites

  • 1 year later...

The "Visitors online" gets the number of connections that were started within 900 seconds (15 minutes) ago. See the getVisitorsOnline() function in modules/statshome/statshome.php:

 

private function getVisitorsNow()
{
return Db::getInstance()->getValue('
SELECT COUNT(DISTINCT cp.`id_connections`)
FROM `'._DB_PREFIX_.'connections_page` cp
WHERE TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900');
}

 

If someone leaves the website one minute after arriving, they will be considered online for another 14 minutes, but not forever. You can decrease the number 900 to a smaller value if you want a more accurate view of exactly how many people are online at the moment.

 

Great thanks for this! I remember coming across this thread 2 years ago and bookmarked it in my head.

 

It was hell trying to find it again...need to use real bookmarks next time.

Link to comment
Share on other sites

×
×
  • Create New...