Docs

PostHog SwiftUI Autocapture: Track Taps Without Duplicates

PostHog SwiftUI autocapture records control taps on iOS. See which event properties to track, how to label controls and avoid duplicate events.

Analytics

SwiftUI apps have long been awkward to instrument. UIKit autocapture hooks into view controllers and responders, but SwiftUI controls are declarative and often invisible to those hooks. The result is a common gap: teams adopt SwiftUI, autocapture goes quiet, and nobody notices until a product manager asks why tap data for the new screens is empty.

PostHog’s changelog for 2 October 2026 describes opt-in autocapture of SwiftUI control taps in the iOS SDK. It uses .postHogLabel markers to give controls useful names, and is designed to avoid duplicate events where a SwiftUI control wraps a UIKit one.

Without it you either hand-write an event for every button, which drifts out of date, or you fly blind on whole sections of your app. With it, you still need discipline about naming and noise.

Data Points to Track

  • Control label: the value supplied via .postHogLabel, which should be stable and human-readable
  • Screen or view name where the tap occurred
  • Control type: button, toggle, picker, link or custom
  • Tap count per session for each labelled control
  • Duplicate event rate: how often two events fire for one tap, which should be near zero
  • Unlabelled tap share: proportion of captured taps with no explicit label, a measure of instrumentation quality
  • App version and iOS version, so you can see adoption of the new SwiftUI screens by release

Setup Steps

  1. Update the PostHog iOS SDK to the release that includes SwiftUI autocapture.
  2. Enable the opt-in configuration for SwiftUI control taps in your SDK setup.
  3. Add .postHogLabel to key controls such as sign-up, purchase and paywall buttons, using a naming convention such as screen_action.
  4. Test on a device by tapping each labelled control and checking in the live events view that exactly one event arrives.
  5. Check mixed screens. Where SwiftUI hosts UIKit views, or the reverse, confirm there are no duplicate events.
  6. Create a dashboard showing taps by label, plus the unlabelled tap share.

Actionable Insights

Start with the unlabelled share. If more than a fifth of taps lack a label, your funnels will be made of vague events and hard to trust. Label the top ten controls by volume first.

Next, compare tap counts to downstream conversion. A control that is tapped often but rarely leads to the next step usually has unclear copy or a confusing destination. Controls with almost no taps may be hidden, mis-sized or simply unwanted, and are candidates for removal.

Finally, treat autocapture as a discovery tool, not a replacement for core business events. Purchase, subscription and activation events should still be explicit, versioned and tested.

Expert help

Need help tracking this in your app?

Our team sets up analytics pipelines for mobile and web teams every day. Talk to us and get your first events flowing in under an hour.

Talk to an expert