Track User Authentication

Prev Next

Use this page to instrument the authentication flow in your iOS app — login, logout, and registration. The SDK does not provide dedicated authentication APIs; instead, you use action events for the moments themselves and user categories to attach the user identity once login succeeds.

What to track

Moment

How to track

Login successful

trackAction(MIActionEvent("Login")) with attached MIUserCategories carrying customerId.

Login failed

trackAction(MIActionEvent("LoginFailed")) with optional event parameters describing the reason.

Logout

trackAction(MIActionEvent("Logout")). Optionally reset the SDK singleton if you want to drop session continuity.

Registration

trackAction(MIActionEvent("Registration")) with the new user's customerId via MIUserCategories.

Example: track a successful login

let user = MIUserCategories(customProperties: nil)
user.customerId = "user-12345"

let action = MIActionEvent(name: "Login")
action.userCategories = user

MappIntelligence.shared()?.trackAction(action)
MIUserCategories *user = [[MIUserCategories alloc] initWithCustomProperties:nil];
user.customerId = @"user-12345";

MIActionEvent *action = [[MIActionEvent alloc] initWithName:@"Login"];
action.userCategories = user;

[[MappIntelligence shared] trackAction:action];

Example: track logout

MappIntelligence.shared()?.trackAction(MIActionEvent(name: "Logout"))
[[MappIntelligence shared] trackAction:[[MIActionEvent alloc] initWithName:@"Logout"]];

Privacy notes

  • Only attach MIUserCategories after the user has consented to analytics tracking.

  • If Anonymous Tracking is enabled, do not include personally identifiable user data in MIUserCategories.

  • Use customerId as a stable, internal identifier — not the user's email.

Related: Events, Users, User Matching, Anonymous Tracking.