March 12, 2026

Adding Analytics to Your Vibe-Coded iOS App with PostHog

You shipped an iOS app with Cursor, Claude, or another AI coding tool. It's live. People are downloading it. But are they actually using it? How many visitors do you get per week? Is that number going up or down?

PostHog is free for up to 1 million events per month, self-serve, and takes about ten minutes to integrate. Once it's running, PocketHog puts those metrics on your iPhone home screen so you can see them without opening a browser.

Here's the full setup, from zero analytics to live widgets on your phone.

Why PostHog?

For indie and vibe-coded apps, PostHog hits a sweet spot: generous free tier, no credit card required, open source, and excellent documentation. It captures events, tracks unique users, and gives you trend data out of the box with autocapture.

Alternatives like Mixpanel and Amplitude work too, but PostHog's free tier is the most generous for solo developers, and its HogQL query engine is powerful enough to grow into.

Step 1: Add the PostHog iOS SDK

Add the PostHog iOS SDK to your Xcode project via Swift Package Manager:

  1. In Xcode, go to File → Add Package Dependencies.
  2. Enter the URL: https://github.com/PostHog/posthog-ios
  3. Add the PostHog library to your app target.

Step 2: Initialize PostHog

In your app's entry point (e.g., @main App struct), configure the SDK with your project API key and host:

import PostHog

@main
struct MyApp: App {
    init() {
        let config = PostHogConfig(
            apiKey: "phc_your_project_api_key",
            host: "https://us.i.posthog.com"  // or eu.i.posthog.com
        )
        config.captureApplicationLifecycleEvents = true
        PostHogSDK.shared.setup(config)
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

With captureApplicationLifecycleEvents enabled, PostHog automatically tracks app opens, installs, and updates. You'll immediately see visitor data in your PostHog dashboard.

Step 3: Track Custom Events

Beyond autocapture, track the events that matter to your app — signups, purchases, key feature usage:

PostHogSDK.shared.capture("signup_completed")

PostHogSDK.shared.capture(
    "purchase_made",
    properties: ["plan": "pro", "price": 9.99]
)

These events become selectable as conversion metrics in PocketHog, so you can track them alongside visitor counts on your home screen.

Step 4: Monitor from Your Phone with PocketHog

Once PostHog is collecting data, install PocketHog on the App Store and connect it with a Personal API key (different from the project API key you used in your app code).

Create a Personal API key in PostHog under Settings → Personal API Keys with these scopes:

  • project (read)
  • query (read)
  • event_definition (read)

Paste it into PocketHog, select your region, and you're connected. All your projects appear in a scrollable feed with live metrics.

Step 5: Add a Home Screen Widget

Long-press your home screen, tap +, search for PocketHog, and add a small or medium widget. Edit the widget to select which project it tracks. The widget refreshes every 30 minutes in the background.

You can configure a secondary conversion metric per project — pick your signup_completed or purchase_made event and it'll appear on the widget alongside your visitor count.

The Result

You now have a complete analytics pipeline: PostHog SDK in your app capturing events, PostHog's cloud processing the data, and PocketHog on your phone displaying it as a live home screen widget. No browser tabs, no checking dashboards — your metrics are always visible.

For a vibe-coded app, this is the right level of instrumentation: enough to know if your app is growing, without the overhead of a full analytics team.

Next Steps

For a detailed walkthrough on setting up the widget, read how to put PostHog analytics on your iPhone home screen. If you're still deciding on an analytics platform, see our comparison of analytics tools for indie iOS apps.

PocketHog is an independent third-party client and is not affiliated with PostHog, Inc.