PostHog Mobile Analytics Tracker

Track screen views, in-app events, and user engagement across your mobile app with PostHog. Get full visibility into how users navigate and interact with your product.

Mobile analyticsScreen trackingIn-app eventsUser engagement

The Challenge

Mobile analytics is harder than web analytics. You cannot just drop a script tag on a page. Every screen transition, tap, and gesture needs to be instrumented individually in code, deployed through app store review cycles, and validated on multiple devices. By the time you realize you forgot to track a key screen or event, it takes another release cycle to fix it. You need a way to set up and validate mobile tracking without waiting for code deploys.

What This Prompt Does

Track Screen Views

Record every screen transition with names, paths, and navigation context for session flow analysis

Capture In-App Events

Send events for taps, swipes, purchases, and feature usage with full device context

Identify Mobile Users

Associate devices with users and set properties like subscription tier, OS version, and app version

Map Session Flows

Visualize how users navigate through your app and identify the most common paths

The Prompt

The Prompt

Task

Use @PostHog/Track Screen ViewName it "PostHog/Track Screen View" and call it with @PostHog/Track Screen View to record mobile screen views as users navigate through your app, @PostHog/Capture EventName it "PostHog/Capture Event" and call it with @PostHog/Capture Event to capture in-app engagement events like taps, swipes, form submissions, and feature usage, and @PostHog/Identify UserName it "PostHog/Identify User" and call it with @PostHog/Identify User to identify mobile users with their properties. This builds a complete mobile analytics setup in PostHog that shows how users move through your app and which features drive engagement.

Input

The user provides:

  1. Screen names and paths to track (e.g., "Home Screen", "Profile Settings", "Checkout")
  2. In-app events to capture (e.g., "button_tapped", "item_added_to_cart", "search_performed")
  3. User identifier and properties (e.g., user ID, device type, app version)
  4. Optional: engagement metrics to focus on (session length, feature adoption, retention signals)

Example: "Track mobile analytics for our fitness app: screen views for Home, Workout, Progress, and Profile screens. Capture workout_started, exercise_completed, and streak_achieved events. Identify the user with their subscription tier and device info."

Context

Screen View Tracking

  1. Use @PostHog/Track Screen ViewName it "PostHog/Track Screen View" and call it with @PostHog/Track Screen View for each screen the user visits
  2. Include properties with each screen view:
    • Screen name (human-readable, e.g., "Workout Detail")
    • Screen path or route (e.g., "/workout/detail")
    • Previous screen (for navigation flow analysis)
    • App section or tab (e.g., "training", "social", "profile")
  3. Track screens in the order users navigate to build session flow visibility
  4. Note time spent context where available

In-App Event Capture

  1. Use @PostHog/Capture EventName it "PostHog/Capture Event" and call it with @PostHog/Capture Event for meaningful user interactions:
    • Core actions: feature used, item created, content viewed
    • Engagement signals: share, save, favorite, comment
    • Commerce events: add to cart, purchase, subscription change
    • Error events: crash, timeout, failed action
  2. Include contextual properties:
    • Screen where the action occurred
    • Content or feature identifier
    • User state (logged in, trial, premium)
    • Device context (OS version, app version, device model)
  3. Use consistent naming: "object_action" format (e.g., "workout_started", "photo_uploaded")

Mobile User Identification

  1. Use @PostHog/Identify UserName it "PostHog/Identify User" and call it with @PostHog/Identify User to associate the device with a known user
  2. Set mobile-specific properties:
    • Device type (iOS/Android), OS version, app version
    • Subscription tier, account type
    • Push notification status (enabled/disabled)
    • First app open date, total sessions
  3. Update properties when they change (e.g., app update, plan change)

Engagement Analysis

After tracking is set up:

  • Summarize the screen flow recorded
  • List all events captured with their properties
  • Identify which screens and features show the most engagement
  • Flag any gaps in tracking coverage

Output

Mobile Analytics Setup Summary:

User Identified:

  • Distinct ID: [user_id]
  • Device: [device_type] / [os_version]
  • App version: [version]
  • Properties set: [list]

Screen Views Tracked: | Screen | Path | Properties | Status | |--------|------|-----------|--------| | [Screen Name] | [/path] | [key props] | Tracked |

In-App Events Captured: | Event | Screen Context | Properties | Status | |-------|---------------|-----------|--------| | [event_name] | [screen] | [key props] | Sent |

Session Flow: [Screen 1] -> [Screen 2] -> [Screen 3] -> ...

Coverage Summary:

  • Screens tracked: [count]
  • Events captured: [count]
  • User properties set: [count]
  • Ready to analyze in PostHog mobile analytics

Example Usage

Try asking:

  • "Track screen views for our fitness app: Home, Workout, Progress, and Profile screens for user_456 on iOS 17"
  • "Capture in-app events for our e-commerce app: product_viewed, add_to_cart, and checkout_completed with product and price properties"
  • "Set up mobile analytics for our meditation app: track session screens, capture meditation_started and meditation_completed events, identify the user with their subscription tier"