eealeivan/mixpanel-csharp

setting user for a session

Closed this issue · 9 comments

hbrof commented

do you have any examples for setting the user for the sessions. for some reason, they are all showing as one session even tracking across multiple ssytems with a unique id on each.

thanks

Can you please provide a bit more information? I don't understand what exactly do you mean by session.

hbrof commented

sorry for the delay, very busy last few days. If we want to track a user from login to the application thru to logout, my asumption is that that is a session. if we want to see how different users are using the software, we would track them from login thru logout and be able to see of the chosing steps in between.

This library is not doing any identity management automatically. You will need to set DistinctId property for each message you send to Mixpanel that will identify the user.

There are 3 ways of doing that:

  • Add DistinctId property to message that you want to send;
  • Use a needed method override that takes DistinctId as a parameter;
  • Set DistinctId via super properties

Please check these examples:

So you will need to generate an ID for user and send it with each message. This way you will be able to track specific user activity. If user ID changes (for example when user registers) then you can use https://github.com/eealeivan/mixpanel-csharp/wiki/Sending-messages#alias method for creating a link between two ID's.

hbrof commented

Thanks for the follow-up. So we have been using a unique id that we create when first running the software. its based on the machine name and the datetime. I guess what i am confused about, is the concept of a session start and session end? Ie - this user is on the system from when he logs in until when he logs or timesout. In reading this, on the mixpanel site, https://help.mixpanel.com/hc/en-us/articles/360021959052-Client-Side-Session-in-Mixpanel; it is doing two things 1) setting a timeout in case not reported end of session and 2) checking to see if session still active. i did not see any examples of this with the csharp library. Is there something for this?

thanks,
Harvey

Thanks for the update. I will reopen the issue and will check for details.

Can you please also describe a bit more about your use case? What kind of app do you have?

hbrof commented

Sure, we have a retail management system. Different users with different levels of permissions log in and perform various tasks throughout the day. We want to capture their flow through the system as they perform those tasks through the system.

I didn't want to open a new ticket, but can you please explain how can we set properties to a user? My understanding is that the super properties are for this exactly, however when I sent an event to mixpanel with track, most of my prroperties were not recognized as user properties, but rather as event properties (you can notice this when you press "filter" in an event, when you get it right, you see the properties inside the "User" with an arrow to navigate all of its properties, but in this case the properties were simply text properties of the event. In segment there's an "Identify", and in the MixPanel docs all they say is "use your SDK identify method".

I would love to call some method that doesn't track any event, jsut sends user data like location, email, etc etc, and THEN with the same distinct id start sending events with .TrackAsync

Hi @Matiquiel,

You can use variety of People* methods to set various user properties.

Here is an example of PeopleSet method:

var mc = new MixpanelClient("e3bc4100330c35722740fb8c6f5abddc");
await mc.PeopleSetAsync(new {
    DistinctId = "12345",
    Ip = "111.111.111.111",
    FirstName = "Darth",
    LastName = "Vader",
    Name = "Darth Vader",
    Email = "darth.vader@gmail.com",
    Phone = "123456",
    Sex = "M",
    Kills = 215
});