Generated banner for Integration Android
Generated logo for Integration Android

Integration Android

PostHogOfficialCreated by PostHog

  • Skill
  • Tool integration
  • Data and AI
  • MIT
  • No issues found

From the author

PostHog integration for Android applications
— the description by PostHog

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a structured approach to integrating the PostHog Android SDK into mobile applications. It covers the full lifecycle of the integration, from initial configuration in the Application class to advanced features like user identification, custom event tracking, and error reporting. The skill emphasizes best practices such as using environment variables for sensitive keys and ensuring non-blocking, asynchronous data collection.

What it does

  • Guides the setup of PostHog SDK dependencies in Gradle.
  • Demonstrates proper initialization within the Application class.
  • Provides patterns for identifying users during authentication flows.
  • Enables automatic screen view tracking and application lifecycle event capture.
  • Shows how to implement custom event tracking with properties.
  • Includes instructions for enabling session replay and error tracking.

When to use it

  • When you need to add product analytics to an Android app.
  • When you want to track user behavior and screen navigation automatically.
  • When you need to implement crash reporting and error tracking.
  • When you need to correlate client-side sessions with backend events.

Advantages

  • Ensures consistent and efficient SDK initialization.
  • Promotes secure handling of API keys via environment variables.
  • Provides clear patterns for identifying users and tracking custom events.
  • Reduces boilerplate by leveraging automatic lifecycle and screen tracking.

Usage examples

“How do I initialize PostHog in my Android app?”
The agent provides the code to initialize the PostHog SDK within the Application class's onCreate method using a configuration object.
“How can I track a user signup event in my Android app?”
The agent demonstrates using the PostHog.capture function with the event name and relevant properties.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/posthog/integration-android/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip integration-android.zip -d .agents/skills

Documentation by PostHog

PostHog integration for Android

This skill helps you add PostHog analytics to Android applications.

Workflow

Follow these steps in order to complete the integration:

  1. basic-integration-1.0-begin.md - PostHog Setup - Begin ← Start here

  2. basic-integration-1.1-edit.md - PostHog Setup - Edit

  3. basic-integration-1.2-revise.md - PostHog Setup - Revise

  4. basic-integration-1.3-conclude.md - PostHog Setup - Conclusion

Reference files

  • references/EXAMPLE.md - Android example project code

  • references/android.md - Android - docs

  • references/identify-users.md - Identify users - docs

  • references/basic-integration-1.0-begin.md - PostHog setup - begin

  • references/basic-integration-1.1-edit.md - PostHog setup - edit

  • references/basic-integration-1.2-revise.md - PostHog setup - revise

  • references/basic-integration-1.3-conclude.md - PostHog setup - conclusion

The example project shows the target implementation pattern. Consult the documentation for API details.

Key principles

  • Environment variables: Always use environment variables for PostHog keys. Never hardcode them.

  • Minimal changes: Add PostHog code alongside existing integrations. Don't replace or restructure existing code.

  • Match the example: Your implementation should follow the example project's patterns as closely as possible.

Framework guidelines

  • Adapt dependency configuration to the appropriate build.gradle(.kts) file according to the project gradle version

  • Call PostHogAndroid.setup() only once in the Application class's onCreate() method, so it's initialized as early as possible and only once.

  • Initialize PostHog in the Application class's onCreate() method

  • Ensure every activity has a android:label to accurately track screen views.

Identifying users

Identify users during login and signup events. Refer to the example code and documentation for the correct identify pattern for this framework. If both frontend and backend code exist, pass the client-side session and distinct ID using X-POSTHOG-DISTINCT-ID and X-POSTHOG-SESSION-ID headers to maintain correlation.

Error tracking

Add PostHog error tracking to relevant files, particularly around critical user flows and API boundaries.

Files

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
PostHog
Publisher
PostHog (Official)
Source
PostHog/skills · skills/posthog/integration/skills/android · commit a5d30e7
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Also distributed in
PostHog/skills

AutoGineer is not affiliated with or endorsed by PostHog.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download integration-android.zip