shetabit/visitor

How can I get online guest count ?

codes-zain opened this issue · 3 comments

Hi
Is it possible to get online visitor or guest users that are not login in ?
if is possible how can I do that

+1
I looked at the source code of the package and came to the conclusion that there is currently no available method that could get the number of guests.
So I'm surprised the package does not provide this functionality, or am I wrong?

Since guests are also logged into the visits table, then I see only one way, this is to create my query to the visits table.
For example:

\DB::table('visits')
        ->select('id')
        ->where('created_at', '>=', \Carbon\Carbon::now()->subMinutes(3))
        ->whereNull('visitor_id')
        ->groupBy('ip')
        ->get()
        ->count();

Or without groupBy()

\DB::table('visits')
        ->selectRaw('COUNT(DISTINCT(ip)) as count')
        ->where('created_at', '>=', \Carbon\Carbon::now()->subMinutes(3))
        ->whereNull('visitor_id')
        ->get();

But we are faced with a problem, if a user entered the site as a guest and then logged in, then in the statistics there will be 1 online guest and 1 online user, which is not true.
image
image

And the second problem: the number of guests will be taking into account search robots

hey did u work on the guest visitors problem

please add this feature to the package and send a pull request. I will merge it.