The SDK assigns a unique userId when an identify event is triggered. This parameter uniquely identifies a user within the database after they log in or sign up.
The following snippet highlights how to obtain the user’s userId:
valuserId=analytics.userId
StringuserId=analytics.getUserId();
The above snippet returns the following information:
Property name
Return type
Description
userId
String?
The stored userId for the user.
Note: The SDK returns null if the Analytics instance is shut down.
Fetch anonymous ID
anonymousId is a unique identifier automatically generated by the SDK to track unidentified users, for example, users before they log in or sign up. This ID persists across sessions and allows tracking user behavior before they are identified explicitly.
The following snippet highlights how to obtain the user’s anonymousId:
valanonymousId=analytics.anonymousId
StringanonymousId=analytics.getAnonymousId();
The above snippet returns the following information:
Property name
Return type
Description
anonymousId
String?
The stored anonymousId for the user.
Note: The SDK returns null if the Analytics instance is shut down.
Fetch user traits
The SDK uses the traits object to store any additional user attributes, for example, name, email, custom properties, etc. associated with an identify event. These traits allow for richer user profiling and segmentation.
The following snippet highlights how to obtain the user’s userId:
valtraits=analytics.traits
Map<String,Object>traits=analytics.getTraits();
The above snippet returns the following information:
Property name
Return type
Description
traits
JsonObject?
A structured object containing the user’s traits.
Note that:
The SDK returns null if the Analytics instance is shut down.
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.