# Swift and iOS (https://talivia.com/docs/mobile-analytics/swift)



Add the public Talivia package through Swift Package Manager in Xcode. Select version `0.1.0` from:

```text
https://github.com/talivia-group/swift.git
```

In another Swift package, add `.package(url: "https://github.com/talivia-group/swift.git", from: "0.1.0")` and depend on the `Talivia` library product.

## Initialize and track [#initialize-and-track]

```swift
import Talivia

let analytics = try Talivia(
    websiteId: "YOUR_WEBSITE_UUID",
    hostname: "example.com"
)

try await analytics.screen("Home")
try await analytics.track("signup_completed", data: ["plan": .string("pro")])
try await analytics.identify("your-stable-user-id")
// On logout: analytics.reset()
```

The methods are main-actor isolated. Call `screen()` when your app shows another screen; the package does not observe SwiftUI or UIKit navigation automatically. Record product events after the action occurs, and initialize only when collection is permitted by your privacy settings.

Use the same Website ID and hostname as your website for a shared workspace. Matching stable IDs link known account identity records, while current funnels remain visitor-based across devices. The in-memory retry queue holds up to 100 events. Verify purchase revenue on a trusted server; app-store purchase tracking is not automatic.

[See iOS analytics](https://talivia.com/mobile-app-analytics/swift) · [View package source](https://github.com/talivia-group/swift)
