Jump to content

Back Office and Stats


Recommended Posts

here is what I understand

1. the visitors online at "Home Page" of your back office include customer (logged in) and none customer (guest).
2. At "Stats Tab", visitors online means guest only and customers online means logged in customers

Usually you(we) will think that it should be: total of 1 = total of 2
but the result is different because the data is corrected in different criteria.

If you understand SQL, you will find out why they are different.

Just for your reference, here are the SQL code (from PS version 1.3.2.3)
Home - on line visitors

       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');




Stats Tab - Visitors Online

        return Db::getInstance()->ExecuteS('
       SELECT c.id_guest, c.ip_address, c.date_add, c.http_referer, pt.name as page
       FROM `'._DB_PREFIX_.'connections` c
       LEFT JOIN `'._DB_PREFIX_.'connections_page` cp ON c.id_connections = cp.id_connections
       LEFT JOIN `'._DB_PREFIX_.'page` p ON p.id_page = cp.id_page
       LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON p.id_page_type = pt.id_page_type
       INNER JOIN `'._DB_PREFIX_.'guest` g ON c.id_guest = g.id_guest
       WHERE (g.id_customer IS NULL OR g.id_customer = 0)
       AND cp.`time_end` IS NULL
       AND TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900
       GROUP BY c.id_connections
       ORDER BY c.date_add DESC');




Stats Tab - Customers Online

        return Db::getInstance()->ExecuteS('
       SELECT u.id_customer, u.firstname, u.lastname, pt.name as page
       FROM `'._DB_PREFIX_.'connections` c
       LEFT JOIN `'._DB_PREFIX_.'connections_page` cp ON c.id_connections = cp.id_connections
       LEFT JOIN `'._DB_PREFIX_.'page` p ON p.id_page = cp.id_page
       LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON p.id_page_type = pt.id_page_type
       INNER JOIN `'._DB_PREFIX_.'guest` g ON c.id_guest = g.id_guest
       INNER JOIN `'._DB_PREFIX_.'customer` u ON u.id_customer = g.id_customer
       WHERE cp.`time_end` IS NULL
       AND TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900
       GROUP BY c.id_connections
       ORDER BY u.firstname, u.lastname');

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...