Mobile SDKsidentify()

identify()

The identify() method links an anonymous app user to a known identity. Call it when the user logs in, registers, or updates their profile.

Syntax

iOS (Swift)

Datafly.shared.identify(userId: String, traits: [String: Any]? = nil)

Android (Kotlin)

Datafly.identify(userId: String, traits: Map<String, Any>? = null)

React Native / Cordova

DataflySignal.identify(userId, traits?)

Flutter

await DataflySignal.identify(userId, traits: {...})

Parameters

ParameterTypeRequiredDescription
userIdStringYesUnique, stable identifier (e.g., database ID)
traitsDictionary/MapNoKey-value pairs describing the user

Basic usage

// iOS -- after login
Datafly.shared.identify(userId: "user-123", traits: [
    "email": "[email protected]",
    "name": "Jane Doe",
    "plan": "professional",
])
// Android -- after login
Datafly.identify("user-123", mapOf(
    "email" to "[email protected]",
    "name" to "Jane Doe",
    "plan" to "professional"
))

How identity works on mobile

When identify() is called:

  1. The userId is stored in memory and included in all subsequent events
  2. Traits are merged with previously set traits (new values overwrite existing keys)
  3. An identify event is sent to the Ingestion Gateway
  4. The server links userId to the anonymousId, creating a unified profile
Before identify():
  anonymousId: "a1b2c3d4-..."  (unknown user)

After identify("user-123"):
  anonymousId: "a1b2c3d4-..."  (linked)
  userId: "user-123"            (known user)

All subsequent track() and screen() calls include both anonymousId and userId.

PII handling

Traits containing PII (email, name, phone) are hashed server-side using SHA-256 before delivery to vendor APIs. Raw PII is stored only in your own database. This enables Meta Advanced Matching, Google Enhanced Conversions, and TikTok matching without exposing user data.

Trait merging

Traits merge across multiple identify() calls:

// First call
Datafly.shared.identify(userId: "user-123", traits: ["email": "[email protected]", "plan": "starter"])
 
// Later call -- plan updated, email preserved
Datafly.shared.identify(userId: "user-123", traits: ["plan": "professional"])
 
// Internal state: { email: "[email protected]", plan: "professional" }

Common traits

TraitTypeDescription
emailStringEmail address
nameStringFull name
firstNameStringFirst name
lastNameStringLast name
phoneStringPhone number (E.164 format preferred)
planStringSubscription plan or tier
createdAtStringISO 8601 date of account creation
companyStringCompany name
⚠️

Use a stable, unique identifier as the userId (database primary key or UUID). Do not use email addresses as the userId — users may change their email. Pass email as a trait instead.