meteor-user-status
meteor-user-status copied to clipboard
How to track anonymous users?
Is there a way to track anonymous users?
I found your answer here: http://stackoverflow.com/questions/13544333/how-to-track-the-number-of-anonymous-users-server-side-in-meteor
I'm assuming I would have to look at the server side in memory UserStatus?
Yep. You can also use the connectionX
events as shown in the README.
If you want to do something on the client side, you may want to publish some information about the user as I described in #53.
I find it very easy to combine mizzao:user-status
with artwells:accounts-guest
- it creates a guest user for the visitors, which user-status works great with out of the box.
Just needed to do this myself. Getting the anonymous user count is as easy as querying the in-memory UserStatus.connections
collection for connections without a userId
.
UserStatus.connections.find({userId: {$exists: false}}).count()
This leads to another question... I want to get the above anonymous user count reactively to my client... it seems this is really hard/impossible if I don't have the UserStatus.connections
collection setup on my client as well so I can do a proper pub/sub. How would I create a "client version" of this collection so I can connect to the "server-only" version? Otherwise it's damn near impossible get a "server-only" var reactively to the client.