iOS (Swift)
Install the iOS SDK and track app opens and screens.
Last updated June 3, 2026
Install the iOS SDK, configure the site ID, and send app_open and screen_view events. Lifecycle events can be sent explicitly with trackEvent when your app observes them. See what the SDK can do →.
Prerequisites
- A Grometrics site ID from Settings > Tracking
- Access to the mobile app code
- A debug build or simulator for verification
Steps
Add version 1.1.1
Add the Grometrics Swift package in Xcode Package Dependencies and select the 1.1.1 tag.
Package URL
1https://github.com/codelinglabs/grometrics-ios.gitCreate and start the tracker
Keep one tracker instance for the app lifecycle.
Replace YOUR_SITE_ID with your site ID from Settings > Tracking.
App.swift
1let grometrics = GrometricsTracker(2configuration: .init(websiteId: "YOUR_SITE_ID")3)45await grometrics.start()
Identify and reset
Identify after login so anonymous and server activity merge. Reset before sign-out on a shared device.
Auth.swift
1await grometrics.identify(userId: user.id)23await grometrics.reset()4await auth.signOut()
Track screens
Send readable screen names from navigation changes.
CheckoutView.swift
1await grometrics.trackScreen(2name: "Checkout",3path: "/checkout"4)
Options / Configuration
| Option | Type | Required | Description |
|---|---|---|---|
| websiteId | string | ✓ | Your Grometrics site ID |
| appVersion | string | no | Populates app version filters |
What happens next
Open the app in a simulator and confirm app_open and screen_view in Realtime.
Verify your setup
Verify your setup
Troubleshooting
No event appears
Confirm the site ID matches Settings > Tracking and that the latest published code is running.
Was this page helpful?