meteor-user-status icon indicating copy to clipboard operation
meteor-user-status copied to clipboard

How to track anonymous users?

Open hexsprite opened this issue 9 years ago • 5 comments

Is there a way to track anonymous users?

hexsprite avatar Feb 05 '15 20:02 hexsprite

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?

hexsprite avatar Feb 05 '15 20:02 hexsprite

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.

mizzao avatar Feb 05 '15 20:02 mizzao

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.

KristerV avatar May 28 '15 08:05 KristerV

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()

evolross avatar Oct 13 '15 01:10 evolross

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.

evolross avatar Oct 13 '15 02:10 evolross