Question

Tracking only logged users

  • 9 August 2019
  • 1 reply
  • 42 views

Badge

In our application we started the tracking for all users (anonymous and logged-in) but after reaching the MTUs limit we decided to only track users that are logged-in.

To achieve this, we remove the script from our index.html and make sure it is only loaded after the user completes the login. So, when it happens, we load the script and call :

mixPanel.identify('1234') //same ID the user has in our application


The problem is that I'm still seeing anonymous people event's on Mixpanel (with random generated distinct ids) in pages that are only available for logged users (URL /my-account, as example).

At the moment I don't know how is it possible, because if the user is in a restricted page it means that he is logged in - and the mixpanel.identify was called before. I wasn't expecting to see any user with a random distinct id anymore.


Can anyone help us, please?


PS: We never call mixPanel.alias because what the user did before the registration/login does not matter to us.





1 reply

Userlevel 3
Badge

Hi @germanoroettgers!

Being that you mention an index.html file, I am assuming you are using Mixpanel Javascript library? In this case, if you are using Mixpanel's client-side libraries (Javascript, iOS, Android) with tracking calls [mixpanel.track()] on public pages that anonymous users/users that are not logged in can see, this will collect default properties info. Thus it will generate a random distinct id for those users along with their default properties.

I am not sure how your user flow works for not logged-in users vs logged-in users, but some suggestions I have is checking if there is still mixpanel.track() calls on other pages accessible to not logged-in users and removing those mixpanel.track() calls. The reason I mention double checking your mixpanel.track() calls is because loading Mixpanel library on the <head> tag of an html page should only load the library but not send events, events get captured and sent to your project when mixpanel.track() is called.

One last thing I want to mention is that using identify and alias will not generate new distinct Ids, these help with keeping your users identity management healthy when tracking events. Mixpanel created an implementation course that was super helpful for me to understand calls like mixpanel.track and identity management best practices, I think it could provide more insights for you as well.

I hope this helpful to you!


Reply