Getting Started
Before you begin, ensure your iOS project meets the following requirements:- iOS Deployment Target: 13 or higher.
- Xcode: Version 15 or higher.
Installing the Library
CocoaPods
- Add the Userpilot dependency to your
Podfile. Replace<SDK_VERSION>with the latest version available from CocoaPods.
- Run
pod installin your project directory.
Swift Package Manager
- In Xcode, navigate to File -> Add Packages.
- Enter the package URL:
https://github.com/Userpilot/ios-sdk. - For Dependency Rule, select Up to Next Major Version.
- Click Add Package.
Initialize the SDK
Initialize Userpilot once in your App Delegate or Scene Delegate during app launch to ensure the SDK is ready as soon as your app starts. Replace<APP_TOKEN> with your Application Token from the Environments Page.
Identify Users (Required)
Identify unique users and companies (groups of users) alongside their properties. Once identified, all subsequent tracked events and screens will be attributed to that user. Recommended Usage:- On user authentication (login): Immediately call
identifywhen a user signs in to establish their identity for all future events. - On app launch for authenticated users: If the user has a valid authenticated session, call
identifyat app launch. - Upon property updates: Whenever user or company properties change.
- The
idkey is required in company properties to identify a unique company. - Userpilot supports String, Numeric, and Date types.
- Send date values in ISO8601 format.
- If you plan to use Userpilot’s localization features, pass the user property
locale_codewith a value that adheres to ISO 639-1 format. - Userpilot’s reserved properties have pre-determined types and improve the profiles interface in the dashboard:
- Use key
emailto pass the user’s email. - Use key
nameto pass the user’s or company’s name. - Use key
created_atto pass the user’s or company’s signup date.
- Use key
Track Screens (Required)
Tracking screens is crucial for unlocking Userpilot’s core engagement and analytics capabilities. Screen views are used to trigger eligible in-app experiences, improve targeting, and provide context for analytics by associating subsequent events with the currently active screen.- Auto Capture
- Manual Tracking
Userpilot SDK supports automatic screen tracking for iOS applications, allowing screen views to be captured without manually sending screen events.When Auto Capture is enabled, the SDK automatically detects and tracks screens across your app lifecycle.
Track Events
Log any meaningful action the user performs. Events can be button clicks, form submissions, or any custom activity you want to analyze. Optionally, you can pass metadata with the event to provide specific context.Logout
When a user logs out, calllogout to clear the current user context. This ensures subsequent events are no longer associated with the previous user.
Anonymous Users
If a user is not authenticated, callanonymous to track events without a user ID. This is useful for pre-signup flows or guest user sessions.
Experiences
Trigger a specific experience programmatically using its ID. This API allows you to manually initiate an experience within your application.Configuration (Optional)
| Parameter | Type | Description |
|---|---|---|
| logging | Bool | Enable or disable logs for the SDK. Default: false |
| enableScreenAutoCapture | Bool | Enables automatic screen tracking. Default: false |
| enableInteractionAutoCapture | Bool | Enables automatic interaction capture. Default: false |
| disableRequestPushNotificationsPermission | Bool | Disable push notifications permission request by the SDK. Default: false |
| useInAppBrowser | Boolean | Determines whether to open URLs inside SFSafariViewController or use the system browser. Default: false |
| navigationHandler | UserpilotNavigationDelegate | Handle deep link navigation from experiences and push notifications. |
| analyticsDelegate | UserpilotAnalyticsDelegate | Broadcasts analytics events to external listeners for tracking and reporting. |
| experienceDelegate | UserpilotExperienceDelegate | Notifies about experience display and lifecycle events. |
Sample App
TheSample directory in the GitHub repository contains a full example Swift app providing references for usage of the Userpilot API.