Reputation: 59
I want to display the number of active visitors on my website, I tried using django-tracking
, django-active-users
but none of them worked because they are outdated. I am using Django 3.0.8 and all of those modules aren't supported with django3.
I also tried doing this with Google analytics but their real-time reporting API is in limited beta and not open to everyone. Is there any way I can get this to work using Django active sessions or something?
Upvotes: 1
Views: 591
Reputation: 61
Create a DailyCount
model which has date(DateField)
, active_users(PositiveIntegerField)
.
Then use celery periodic tasks with a function that is triggered at hour=0, minute=0
, i.e., every day.
Create a DailyCount
instance in the triggered function.
Whenever a user visits the site for the first time that day, increase DailyCount.active_users
by 1.
Upvotes: 0