New in CUX: Mobile Analytics. Analyze real user behavior inside your app. Learn More

Identify users and track iOS custom events

Identify users and track iOS custom events

Browse topics

On this page

Connect activity to an internal account ID and send an event when your iOS app confirms an outcome. Initialize the SDK and allow collection before using these examples.

Version covered: 1.1.11. Requires iOS 15 or later.

Identify users

Identification is optional. After your app knows which account is active:

CuxAnalytics.shared.setUserProperties(
    userId: "account-123",
    params: ["plan": "pro"]
)

Use an internal ID rather than an email. Test logout and account switching; do not assume stopping collection clears identity. See Identify mobile users.

Track custom events

Send an event when your app confirms an outcome:

CuxAnalytics.shared.trackEvent(
    eventName: "checkout_completed",
    params: ["currency": "USD", "plan": "pro"],
    label: "subscription"
)

This API uses string parameters. Do not copy Android's typed-event API into your iOS code. Keep sensitive data out of the event and check repeated callbacks for duplicates.

Avoid duplicate events

Send the event from the handler that confirms the outcome. Do not also send it from a view update or an appearance callback. Check retries and repeated callbacks separately.

Screenshot masks do not filter identifiers, user properties or event parameters. Keep those values limited to the context you need.

Verify users and events

Use two synthetic accounts. Complete an action once and check the active identifier, event name, label and string parameters in CUX. Repeat the journey without completing the action and confirm that the success event does not appear.

Test login, logout and switching accounts on the same device. If identity clearing is not documented for your integration, confirm the supported approach with CUX before relying on it on shared devices.

For missing data, follow iOS troubleshooting.