0

I am trying to get total number of logged in and not logged in users currently on particular product page.

<?php 
            $visitor_count = Mage::getModel('log/visitor_online')
            ->prepare()
            ->getCollection()->count();

        if(!empty($visitor_count) && $visitor_count > 0)
        {
            $cnt =  $visitor_count;             
                echo 'Visitors online :'.$cnt;
        }  
?>

Using above code I am getting total number of users active in the website. How should I filter on current product page to see total number of users on current product page.

1 Answer 1

0

You can use Analytic tools ( Google Analytics) to track the reports on pages or links and it provides advanced features.

To get total number of logged in and not logged in users currently on particular product page, you can Use session-level custom variables to distinguish different visitor experiences across sessions.

Session-level custom variables

For example, if your website offers users the ability to login, you can use a custom variable scoped to the session level for user login status. In that way, you can segment visits by those from logged in members versus anonymous visitors.

_gaq.push(['_setCustomVar',
   1,             // This custom var is set to slot #1.  Required parameter.
   'User Type',   // The name of the custom variable.  Required parameter.
   'Member',      // Sets the value of "User Type" to "Member" or "Visitor" depending on status.  Required parameter.
   2              // Sets the scope to session-level.  Optional parameter.
]);

It would be better to go with reporting tools to get good reports for your website.

Track a login event in Google Analytics

2
  • ya thanks for the advice, but isnt there any magento built in function which will tell this kind of feature?
    – Akash
    Commented Feb 1, 2016 at 4:07
  • Unfortunately there is no function to do that. Commented Feb 2, 2016 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.