iOS product analytics installation
Contents
PostHog is available through CocoaPods or as a Swift Package Manager dependency.
Add PostHog to your Podfile: Or install via Swift Package Manager: Initialize PostHog in your AppDelegate: Once installed, PostHog will automatically start capturing events. You can also manually send events to test your integration: By default, for backwards compatibility reasons, events are sent with person profile processing enabled. This means a person profile will be created for each user who triggers an event. If you want to disable person profile processing for certain events, send the event with the following property:Install via CocoaPods
RequiredConfigure PostHog
RequiredSend events
RecommendedNext steps
RecommendedResource Description Capturing events Learn how to capture custom events beyond autocapture Identifying users Associate events with specific users Creating insights Build trends, funnels, and retention charts Group analytics Track events at the company or account level
Swift Package Manager
Add PostHog as a dependency in your Xcode project Package Dependencies and select the project target for your app.
For Swift Package Manager projects, add PostHog to your Package.swift dependencies:
Then add it as a dependency for your target:
SwiftUI configuration
If you're using SwiftUI lifecycle, initialize PostHog in your app's init():
For more advanced options, see the configuration page.