User_id in atomic events table vs. userId in client session context

Hi there,
I have a question about user ids in Snowplow. We have some doubts if the way we are using them is correct or not.

For every mobile event, the value of “userId” from client_session context is sent by the client as soon as we have a user id. But other properties of this context come from Snowplow (for ex. sessionID, sessionIndex, etc.). There is also another field in atomic events called “user_id”. We are not setting a value for this field but still get the values for all the events. From what I understood looking at this, “user_id” in atomic events is the custom user id to identify the user. But we are setting “userId” in client_session context for the same purpose. So my first question is: Is it the correct way to define custom user id or should we set it using the “user_id” field in the atomic events table? And my second question is, now that we are not setting this field “user_id” on the client side, what is the value we are receiving for this field? Does the value come from Snowplow?

It’s also confusing that the field in client_session context schema is called “userId” but in this blogpost under section " Out of the box identifiers on mobile", it’s called “user_id”. Which one is correct?

Thank you!
Mahshad

Hi Mahshad!

I am a bit confused by your post because it seems to imply that you are able to set the userId field in the client_session context entity – as far as I know this should not be an option for you. If you use the session tracking feature provided by the tracker, the userId should always be an auto-generated UUID identifier that is created by the tracker the first time that the app is initialized and does not change. You can inspect the userId in your app using tracker.getSession().getUserId() but there is no setter function provided.

On the other hand the user_id atomic property in events (or the “business user ID” as we sometimes call it) is provided only by you – the tracker does not set it automatically. It is the custom user ID that you use in your system to identify users (e.g., their email address). You can set it using the setUserId(userId) function in SubjectConfiguration. If you don’t set this user_id yourselves, it should be blank in your data.

I hope that makes it a bit more clear, please let us know if you have further questions!