Distinct ID Creation (JavaScript, iOS, Android)

User identification in Mixpanel is handled through a property called "distinct_id". The distinct_id sent with each event determines which user sent the event. All the unique reports in Mixpanel (funnels, retention, uniques in insights), depend on distinct_id to follow a single user. 


The JS library will automatically issue a distinct_id to each user that loads the library. The JS distinct_id is a random, unique, 54-60 character hash, and is stored in a cookie. The cookie is specific to the domain, browser, computer and instance of Mixpanel (project). If you do not choose to manage distinct_id yourself, each time a user shows up in a new browser, on a new machine, or clears their cookies, they will appear to be a new unique user.

Example ID: 13bbf7943e584-0885c2531-5c793977-3e8000-13bbf7943e64cf


Beginning with Objective-C version v3.6.2 and Swift version v2.7.7, Mixpanel no longer uses the IFA(ID for Advertisers) but uses a randomly generated UUID as the default distinct ID instead. 

If you want to use IFV(identifierForVendor) as the distinct_id, you can set MIXPANEL_UNIQUE_DISTINCT_ID=1 in build settings Active Compilation Conditions for swift or Preprocessor Macros for Objective-C on the Mixpanel framework target. The IFV remains constant until a user removes and then re-installs the app, the IFV will change with each installation.

UUID & IFV Example ID: 3688B790-D3C6-45E1-A92A-0F09D346B6C7


The Android library automatically creates a random unique UUID (variant 2, version 4 from RFC 4122) value for distinct_id.

Since the Android library uses a native object to store the distinct_id value, it will persist across sessions and app updates. Post version 3.0, when a user removes and then re-installs the app, they will get a new distinct_id value.

Example ID: f47ac10b-58cc-4372-a567-0e02b2c3d479


Did this answer your question?



Article is closed for comments.