---
description: Unofficial Capacitor plugin for PostHog SDK to track user interactions and events in your app with support for Android, iOS, and Web.
title: Capacitor PostHog Plugin for Android, iOS & Web - Capawesome
image: https://capawesome.io/docs/assets/images/social/plugins/posthog.png
---

[ Skip to content](#capawesomecapacitor-posthog) 

[ 🎉 Introducing **Capawesome Platform** — one platform for Live Updates, Native Builds, App Store Publishing, and Insider SDKs.](https://capawesome.io) 

* [  Formbricks ](/docs/plugins/formbricks/)
* [  Geocoder ](/docs/plugins/geocoder/)
* [  Google Sign-In ](/docs/plugins/google-sign-in/)
* [  libSQL ](/docs/plugins/libsql/)
* [  Live Update ](/docs/plugins/live-update/)
* [  Managed Configurations ](/docs/plugins/managed-configurations/)
* [  Media Session ](/docs/plugins/media-session/)
* [  ML Kit ](/docs/plugins/mlkit/)
* [  NFC ](/docs/plugins/nfc/)
* [  OAuth ](/docs/plugins/oauth/)
* [  Pedometer ](/docs/plugins/pedometer/)
* [  Photo Editor ](/docs/plugins/photo-editor/)
* PostHog [  PostHog ](/docs/plugins/posthog/)
* [  Configuration ](#configuration)
* [  Demo ](#demo)
* [  Usage ](#usage)
* [  API ](#api)
* [  Type Aliases ](#type-aliases)
* [  Advanced ](#advanced)
* [  Changelog ](#changelog)
* [  License ](#license)
* [  Printer ](/docs/plugins/printer/)
* [  Purchases ](/docs/plugins/purchases/)
* [  RealtimeKit ](/docs/plugins/realtimekit/)
* [  Screen Orientation ](/docs/plugins/screen-orientation/)
* [  Screenshot ](/docs/plugins/screenshot/)
* [  Secure Preferences ](/docs/plugins/secure-preferences/)
* [  Speech Recognition ](/docs/plugins/speech-recognition/)
* [  Speech Synthesis ](/docs/plugins/speech-synthesis/)
* [  Share Target ](/docs/plugins/share-target/)
* [  Square Mobile Payments ](/docs/plugins/square-mobile-payments/)
* [  SQLite ](/docs/plugins/sqlite/)
* [  Superwall ](/docs/plugins/superwall/)
* [  Torch ](/docs/plugins/torch/)
* [  Wifi ](/docs/plugins/wifi/)
* [  Zip ](/docs/plugins/zip/)
* [  Cloud ](/docs/cloud/)
* [  Live Updates ](/docs/cloud/live-updates/)
* Advanced
* Integrations
* [  Native Builds ](/docs/cloud/native-builds/)
* [  Configuration ](/docs/cloud/native-builds/configuration/)
* [  Environments ](/docs/cloud/native-builds/environments/)
* Guides
* [  Sample Projects ](/docs/cloud/native-builds/sample-projects/)
* [  Troubleshooting ](/docs/cloud/native-builds/troubleshooting/)
* [  Automations ](/docs/cloud/automations/)
* [  Assist ](/docs/cloud/assist/)
* Account
* Organizations
* [  Organization and User Management ](/docs/cloud/organizations/memberships/)
* [  Single Sign-On (SSO) ](/docs/cloud/organizations/sso/)
* [  Teams ](/docs/cloud/organizations/teams/)
* [  Two-Factor Authentication ](/docs/cloud/organizations/two-factor-authentication/)
* [  Integrations ](/docs/cloud/integrations/)
* [  License Keys ](/docs/cloud/license-keys/)
* [  Webhooks ](/docs/cloud/webhooks/)
* [  Pricing ](https://capawesome.io/pricing/)
* [  FAQ ](/docs/cloud/faq/)
* [  Support ](/docs/cloud/support/)
* [  Contributing ](/docs/contributing/)
* [  LLMs ](/docs/llms/)
* [  Insiders ](/docs/insiders/)
* [  License ](https://capawesome.io/legal/eula/)
* [  Support ](/docs/insiders/support/)
* [  FAQ ](/docs/insiders/faq/)
* [  Blog ](/blog/)
* Categories

* [  Configuration ](#configuration)
* [  Demo ](#demo)
* [  Usage ](#usage)
* [  API ](#api)
* [  Type Aliases ](#type-aliases)
* [  Advanced ](#advanced)
* [  Changelog ](#changelog)
* [  License ](#license)

# @capawesome/capacitor-posthog[¶](#capawesomecapacitor-posthog "Permanent link")

Unofficial Capacitor plugin for [PostHog](https://posthog.com/).[1](#fn:1)

[ ![Deliver Live Updates to your Capacitor app with Capawesome Cloud](../../assets/external/cloud.capawesome.io/assets/banners/cloud-build-and-deploy-capacitor-apps.69628c3f.png) ](https://cloud.capawesome.io/) 

## Newsletter[¶](#newsletter "Permanent link")

Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).

## Compatibility[¶](#compatibility "Permanent link")

| Plugin Version | Capacitor Version | Status         |
| -------------- | ----------------- | -------------- |
| 8.x.x          | \>=8.x.x          | Active support |
| 7.x.x          | 7.x.x             | Deprecated     |

## Installation[¶](#installation "Permanent link")

You can use our **AI-Assisted Setup** to install the plugin. Add the [Capawesome Skills](https://github.com/capawesome-team/skills) to your AI tool using the following command:

`[](#%5F%5Fcodelineno-0-1)npx skills add capawesome-team/skills --skill capacitor-plugins
`

Then use the following prompt:

`` [](#%5F%5Fcodelineno-1-1) Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capawesome/capacitor-posthog` plugin in my project.
 ``

If you prefer **Manual Setup**, install the plugin by running the following commands and follow the platform-specific instructions below:

`[](#%5F%5Fcodelineno-2-1)npm install @capawesome/capacitor-posthog posthog-js
[](#%5F%5Fcodelineno-2-2)npx cap sync
`

### Android[¶](#android "Permanent link")

#### Variables[¶](#variables "Permanent link")

If needed, you can define the following project variable in your app’s `variables.gradle` file to change the default version of the dependency:

* `$androidxCoreKtxVersion` version of `androidx.core:core-ktx` (default: `1.13.1`)
* `$posthogVersion` version of `com.posthog:posthog-android` (default: `3.27.2`)

This can be useful if you encounter dependency conflicts with other plugins in your project.

## Configuration[¶](#configuration "Permanent link")

| Prop                                  | Type                                          | Description                                                                             | Default                    | Since |
| ------------------------------------- | --------------------------------------------- | --------------------------------------------------------------------------------------- | -------------------------- | ----- |
| **apiKey**                            | string                                        | The API key of your PostHog project.                                                    | 7.1.0                      |       |
| **apiHost**                           | string                                        | The API host of your PostHog instance or reverse proxy.                                 | 'https://us.i.posthog.com' | 8.3.0 |
| **host**                              | string                                        | The API host of your PostHog instance. Deprecated alias for apiHost.                    | 'https://us.i.posthog.com' | 7.1.0 |
| **uiHost**                            | string                                        | The PostHog UI host used when apiHost points to a reverse proxy. Only available on Web. | 8.3.0                      |       |
| **enableSessionReplay**               | boolean                                       | Whether to enable session recording automatically.                                      | false                      | 7.3.0 |
| **sessionReplayConfig**               | [SessionReplayOptions](#sessionreplayoptions) | Session recording configuration options.                                                | 7.3.0                      |       |
| **captureApplicationLifecycleEvents** | boolean                                       | Whether to capture application lifecycle events.                                        | true                       | 8.3.0 |

### Examples[¶](#examples "Permanent link")

In `capacitor.config.json`:

`[](#%5F%5Fcodelineno-3-1){
[](#%5F%5Fcodelineno-3-2)  "plugins": {
[](#%5F%5Fcodelineno-3-3)    "Posthog": {
[](#%5F%5Fcodelineno-3-4)      "apiKey": 'phc_g8wMenebiIQ1pYd5v9Vy7oakn6MczVKIsNG5ZHCspdy',
[](#%5F%5Fcodelineno-3-5)      "apiHost": 'https://eu.i.posthog.com',
[](#%5F%5Fcodelineno-3-6)      "host": 'https://eu.i.posthog.com',
[](#%5F%5Fcodelineno-3-7)      "uiHost": 'https://eu.posthog.com',
[](#%5F%5Fcodelineno-3-8)      "enableSessionReplay": undefined,
[](#%5F%5Fcodelineno-3-9)      "sessionReplayConfig": undefined,
[](#%5F%5Fcodelineno-3-10)      "captureApplicationLifecycleEvents": undefined
[](#%5F%5Fcodelineno-3-11)    }
[](#%5F%5Fcodelineno-3-12)  }
[](#%5F%5Fcodelineno-3-13)}
`

In `capacitor.config.ts`:

`[](#%5F%5Fcodelineno-4-1)/// <reference types="@capawesome/capacitor-posthog" />
[](#%5F%5Fcodelineno-4-2)
[](#%5F%5Fcodelineno-4-3)import { CapacitorConfig } from '@capacitor/cli';
[](#%5F%5Fcodelineno-4-4)
[](#%5F%5Fcodelineno-4-5)const config: CapacitorConfig = {
[](#%5F%5Fcodelineno-4-6)  plugins: {
[](#%5F%5Fcodelineno-4-7)    Posthog: {
[](#%5F%5Fcodelineno-4-8)      apiKey: 'phc_g8wMenebiIQ1pYd5v9Vy7oakn6MczVKIsNG5ZHCspdy',
[](#%5F%5Fcodelineno-4-9)      apiHost: 'https://eu.i.posthog.com',
[](#%5F%5Fcodelineno-4-10)      host: 'https://eu.i.posthog.com',
[](#%5F%5Fcodelineno-4-11)      uiHost: 'https://eu.posthog.com',
[](#%5F%5Fcodelineno-4-12)      enableSessionReplay: undefined,
[](#%5F%5Fcodelineno-4-13)      sessionReplayConfig: undefined,
[](#%5F%5Fcodelineno-4-14)      captureApplicationLifecycleEvents: undefined,
[](#%5F%5Fcodelineno-4-15)    },
[](#%5F%5Fcodelineno-4-16)  },
[](#%5F%5Fcodelineno-4-17)};
[](#%5F%5Fcodelineno-4-18)
[](#%5F%5Fcodelineno-4-19)export default config;
`

## Demo[¶](#demo "Permanent link")

A working example can be found here: [robingenz/capacitor-plugin-demo](https://github.com/robingenz/capacitor-plugin-demo)

## Usage[¶](#usage "Permanent link")

`[](#%5F%5Fcodelineno-5-1)import { Posthog } from '@capawesome/capacitor-posthog';
[](#%5F%5Fcodelineno-5-2)
[](#%5F%5Fcodelineno-5-3)const alias = async () => {
[](#%5F%5Fcodelineno-5-4)  await Posthog.alias({
[](#%5F%5Fcodelineno-5-5)    alias: 'new-distinct-id',
[](#%5F%5Fcodelineno-5-6)  });
[](#%5F%5Fcodelineno-5-7)};
[](#%5F%5Fcodelineno-5-8)
[](#%5F%5Fcodelineno-5-9)const capture = async () => {
[](#%5F%5Fcodelineno-5-10)  await Posthog.capture({
[](#%5F%5Fcodelineno-5-11)    event: 'event',
[](#%5F%5Fcodelineno-5-12)    properties: {
[](#%5F%5Fcodelineno-5-13)      key: 'value',
[](#%5F%5Fcodelineno-5-14)    },
[](#%5F%5Fcodelineno-5-15)  });
[](#%5F%5Fcodelineno-5-16)};
[](#%5F%5Fcodelineno-5-17)
[](#%5F%5Fcodelineno-5-18)const flush = async () => {
[](#%5F%5Fcodelineno-5-19)  await Posthog.flush();
[](#%5F%5Fcodelineno-5-20)};
[](#%5F%5Fcodelineno-5-21)
[](#%5F%5Fcodelineno-5-22)const group = async () => {
[](#%5F%5Fcodelineno-5-23)  await Posthog.group({
[](#%5F%5Fcodelineno-5-24)    type: 'group',
[](#%5F%5Fcodelineno-5-25)    key: 'key',
[](#%5F%5Fcodelineno-5-26)    groupProperties: {
[](#%5F%5Fcodelineno-5-27)      key: 'value',
[](#%5F%5Fcodelineno-5-28)    },
[](#%5F%5Fcodelineno-5-29)  });
[](#%5F%5Fcodelineno-5-30)};
[](#%5F%5Fcodelineno-5-31)
[](#%5F%5Fcodelineno-5-32)const identify = async () => {
[](#%5F%5Fcodelineno-5-33)  await Posthog.identify({
[](#%5F%5Fcodelineno-5-34)    distinctId: 'distinct-id',
[](#%5F%5Fcodelineno-5-35)    userProperties: {
[](#%5F%5Fcodelineno-5-36)      key: 'value',
[](#%5F%5Fcodelineno-5-37)    },
[](#%5F%5Fcodelineno-5-38)  });
[](#%5F%5Fcodelineno-5-39)};
[](#%5F%5Fcodelineno-5-40)
[](#%5F%5Fcodelineno-5-41)const register = async () => {
[](#%5F%5Fcodelineno-5-42)  await Posthog.register({
[](#%5F%5Fcodelineno-5-43)    key: 'super-property',
[](#%5F%5Fcodelineno-5-44)    value: 'super-value',
[](#%5F%5Fcodelineno-5-45)  });
[](#%5F%5Fcodelineno-5-46)};
[](#%5F%5Fcodelineno-5-47)
[](#%5F%5Fcodelineno-5-48)const reset = async () => {
[](#%5F%5Fcodelineno-5-49)  await Posthog.reset();
[](#%5F%5Fcodelineno-5-50)};
[](#%5F%5Fcodelineno-5-51)
[](#%5F%5Fcodelineno-5-52)const screen = async () => {
[](#%5F%5Fcodelineno-5-53)  await Posthog.screen({
[](#%5F%5Fcodelineno-5-54)    screenTitle: 'screen',
[](#%5F%5Fcodelineno-5-55)    properties: {
[](#%5F%5Fcodelineno-5-56)      key: 'value',
[](#%5F%5Fcodelineno-5-57)    },
[](#%5F%5Fcodelineno-5-58)  });
[](#%5F%5Fcodelineno-5-59)};
[](#%5F%5Fcodelineno-5-60)
[](#%5F%5Fcodelineno-5-61)const setup = async () => {
[](#%5F%5Fcodelineno-5-62)  await Posthog.setup({
[](#%5F%5Fcodelineno-5-63)    apiKey: 'YOUR_API_KEY',
[](#%5F%5Fcodelineno-5-64)    apiHost: 'https://eu.i.posthog.com',
[](#%5F%5Fcodelineno-5-65)  });
[](#%5F%5Fcodelineno-5-66)};
[](#%5F%5Fcodelineno-5-67)
[](#%5F%5Fcodelineno-5-68)const unregister = async () => {
[](#%5F%5Fcodelineno-5-69)  await Posthog.unregister({
[](#%5F%5Fcodelineno-5-70)    key: 'super-property',
[](#%5F%5Fcodelineno-5-71)  });
[](#%5F%5Fcodelineno-5-72)};
`

## API[¶](#api "Permanent link")

* [alias(...)](#alias)
* [capture(...)](#capture)
* [flush()](#flush)
* [getDistinctId()](#getdistinctid)
* [getFeatureFlag(...)](#getfeatureflag)
* [getFeatureFlagPayload(...)](#getfeatureflagpayload)
* [group(...)](#group)
* [identify(...)](#identify)
* [isFeatureEnabled(...)](#isfeatureenabled)
* [isOptOut()](#isoptout)
* [optIn()](#optin)
* [optOut()](#optout)
* [register(...)](#register)
* [reloadFeatureFlags()](#reloadfeatureflags)
* [reset()](#reset)
* [screen(...)](#screen)
* [setup(...)](#setup)
* [startSessionRecording()](#startsessionrecording)
* [stopSessionRecording()](#stopsessionrecording)
* [unregister(...)](#unregister)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)

### alias(...)[¶](#alias "Permanent link")

`[](#%5F%5Fcodelineno-6-1)alias(options: AliasOptions) => Promise<void>
`

Assign another distinct ID to the current user.

| Param       | Type                          |
| ----------- | ----------------------------- |
| **options** | [AliasOptions](#aliasoptions) |

**Since:** 6.0.0

---

### capture(...)[¶](#capture "Permanent link")

`[](#%5F%5Fcodelineno-7-1)capture(options: CaptureOptions) => Promise<void>
`

Capture an event.

| Param       | Type                              |
| ----------- | --------------------------------- |
| **options** | [CaptureOptions](#captureoptions) |

**Since:** 6.0.0

---

### flush()[¶](#flush "Permanent link")

`[](#%5F%5Fcodelineno-8-1)flush() => Promise<void>
`

Flush all events in the queue.

Only available on Android and iOS.

**Since:** 6.0.0

---

### getDistinctId()[¶](#getdistinctid "Permanent link")

`[](#%5F%5Fcodelineno-9-1)getDistinctId() => Promise<GetDistinctIdResult>
`

Get the current distinct ID.

**Returns:** `Promise<[GetDistinctIdResult](#getdistinctidresult)>`

**Since:** 8.2.0

---

### getFeatureFlag(...)[¶](#getfeatureflag "Permanent link")

`[](#%5F%5Fcodelineno-10-1)getFeatureFlag(options: GetFeatureFlagOptions) => Promise<GetFeatureFlagResult>
`

Get the value of a feature flag.

| Param       | Type                                            |
| ----------- | ----------------------------------------------- |
| **options** | [GetFeatureFlagOptions](#getfeatureflagoptions) |

**Returns:** `Promise<[GetFeatureFlagResult](#getfeatureflagresult)>`

**Since:** 7.0.0

---

### getFeatureFlagPayload(...)[¶](#getfeatureflagpayload "Permanent link")

`[](#%5F%5Fcodelineno-11-1)getFeatureFlagPayload(options: GetFeatureFlagPayloadOptions) => Promise<GetFeatureFlagPayloadResult>
`

Get the payload of a feature flag.

| Param       | Type                                                          |
| ----------- | ------------------------------------------------------------- |
| **options** | [GetFeatureFlagPayloadOptions](#getfeatureflagpayloadoptions) |

**Returns:** `Promise<[GetFeatureFlagPayloadResult](#getfeatureflagpayloadresult)>`

**Since:** 7.1.0

---

### group(...)[¶](#group "Permanent link")

`[](#%5F%5Fcodelineno-12-1)group(options: GroupOptions) => Promise<void>
`

Associate the events for that user with a group.

| Param       | Type                          |
| ----------- | ----------------------------- |
| **options** | [GroupOptions](#groupoptions) |

**Since:** 6.0.0

---

### identify(...)[¶](#identify "Permanent link")

`[](#%5F%5Fcodelineno-13-1)identify(options: IdentifyOptions) => Promise<void>
`

Identify the current user.

| Param       | Type                                |
| ----------- | ----------------------------------- |
| **options** | [IdentifyOptions](#identifyoptions) |

**Since:** 6.0.0

---

### isFeatureEnabled(...)[¶](#isfeatureenabled "Permanent link")

`[](#%5F%5Fcodelineno-14-1)isFeatureEnabled(options: IsFeatureEnabledOptions) => Promise<IsFeatureEnabledResult>
`

Check if a feature flag is enabled.

| Param       | Type                                                |
| ----------- | --------------------------------------------------- |
| **options** | [IsFeatureEnabledOptions](#isfeatureenabledoptions) |

**Returns:** `Promise<[IsFeatureEnabledResult](#isfeatureenabledresult)>`

**Since:** 7.0.0

---

### isOptOut()[¶](#isoptout "Permanent link")

`[](#%5F%5Fcodelineno-15-1)isOptOut() => Promise<IsOptOutResult>
`

Check if the user has opted out of capturing.

**Returns:** `Promise<[IsOptOutResult](#isoptoutresult)>`

**Since:** 8.1.0

---

### optIn()[¶](#optin "Permanent link")

`[](#%5F%5Fcodelineno-16-1)optIn() => Promise<void>
`

Opt in to event capturing.

**Since:** 8.1.0

---

### optOut()[¶](#optout "Permanent link")

`[](#%5F%5Fcodelineno-17-1)optOut() => Promise<void>
`

Opt out of event capturing.

On Web with `cookielessMode: 'on_reject'`: switches to cookieless anonymous tracking. On iOS/Android: stops all event capturing entirely.

**Since:** 8.1.0

---

### register(...)[¶](#register "Permanent link")

`[](#%5F%5Fcodelineno-18-1)register(options: RegisterOptions) => Promise<void>
`

Register a new super property. This property will be sent with every event.

| Param       | Type                                |
| ----------- | ----------------------------------- |
| **options** | [RegisterOptions](#registeroptions) |

**Since:** 6.0.0

---

### reloadFeatureFlags()[¶](#reloadfeatureflags "Permanent link")

`[](#%5F%5Fcodelineno-19-1)reloadFeatureFlags() => Promise<void>
`

Reload the feature flags.

**Since:** 7.0.0

---

### reset()[¶](#reset "Permanent link")

`[](#%5F%5Fcodelineno-20-1)reset() => Promise<void>
`

Reset the current user's ID and anonymous ID.

**Since:** 6.0.0

---

### screen(...)[¶](#screen "Permanent link")

`[](#%5F%5Fcodelineno-21-1)screen(options: ScreenOptions) => Promise<void>
`

Send a screen event.

Only available on Android and iOS.

| Param       | Type                            |
| ----------- | ------------------------------- |
| **options** | [ScreenOptions](#screenoptions) |

**Since:** 6.0.0

---

### setup(...)[¶](#setup "Permanent link")

`[](#%5F%5Fcodelineno-22-1)setup(options: SetupOptions) => Promise<void>
`

Setup the PostHog SDK with the provided options.

**Attention**: This method should be called before any other method. Alternatively, on Android and iOS, you can configure this plugin in your Capacitor Configuration file. In this case, you must not call this method.

| Param       | Type                          |
| ----------- | ----------------------------- |
| **options** | [SetupOptions](#setupoptions) |

**Since:** 6.0.0

---

### startSessionRecording()[¶](#startsessionrecording "Permanent link")

`[](#%5F%5Fcodelineno-23-1)startSessionRecording() => Promise<void>
`

Start session recording.

**Since:** 7.3.0

---

### stopSessionRecording()[¶](#stopsessionrecording "Permanent link")

`[](#%5F%5Fcodelineno-24-1)stopSessionRecording() => Promise<void>
`

Stop session recording.

**Since:** 7.3.0

---

### unregister(...)[¶](#unregister "Permanent link")

`[](#%5F%5Fcodelineno-25-1)unregister(options: UnregisterOptions) => Promise<void>
`

Remove a super property.

| Param       | Type                                    |
| ----------- | --------------------------------------- |
| **options** | [UnregisterOptions](#unregisteroptions) |

**Since:** 6.0.0

---

### Interfaces[¶](#interfaces "Permanent link")

#### AliasOptions[¶](#aliasoptions "Permanent link")

| Prop      | Type   | Description                                        | Since |
| --------- | ------ | -------------------------------------------------- | ----- |
| **alias** | string | The new distinct ID to assign to the current user. | 6.0.0 |

#### CaptureOptions[¶](#captureoptions "Permanent link")

| Prop           | Type                | Description                            | Since |
| -------------- | ------------------- | -------------------------------------- | ----- |
| **event**      | string              | The name of the event to capture.      | 6.0.0 |
| **properties** | Record<string, any> | The properties to send with the event. | 6.0.0 |

#### GetDistinctIdResult[¶](#getdistinctidresult "Permanent link")

| Prop           | Type   | Description              | Since |
| -------------- | ------ | ------------------------ | ----- |
| **distinctId** | string | The current distinct ID. | 8.2.0 |

#### GetFeatureFlagResult[¶](#getfeatureflagresult "Permanent link")

| Prop      | Type              | Description | Since                                                                                      |       |
| --------- | ----------------- | ----------- | ------------------------------------------------------------------------------------------ | ----- |
| **value** | string \| boolean | null        | The value of the feature flag. If the feature flag does not exist, the value will be null. | 7.0.0 |

#### GetFeatureFlagOptions[¶](#getfeatureflagoptions "Permanent link")

| Prop    | Type   | Description                  | Since |
| ------- | ------ | ---------------------------- | ----- |
| **key** | string | The key of the feature flag. | 7.0.0 |

#### GetFeatureFlagPayloadResult[¶](#getfeatureflagpayloadresult "Permanent link")

| Prop      | Type                  | Description                            | Since |
| --------- | --------------------- | -------------------------------------- | ----- |
| **value** | [JsonType](#jsontype) | The value of the feature flag payload. | 7.1.0 |

#### GetFeatureFlagPayloadOptions[¶](#getfeatureflagpayloadoptions "Permanent link")

| Prop    | Type   | Description                  | Since |
| ------- | ------ | ---------------------------- | ----- |
| **key** | string | The key of the feature flag. | 7.1.0 |

#### GroupOptions[¶](#groupoptions "Permanent link")

| Prop                | Type                | Description                                  | Since |
| ------------------- | ------------------- | -------------------------------------------- | ----- |
| **type**            | string              | The group type.                              | 6.0.0 |
| **key**             | string              | The group key.                               | 6.0.0 |
| **groupProperties** | Record<string, any> | The properties to send with the group event. | 6.0.0 |

#### IdentifyOptions[¶](#identifyoptions "Permanent link")

| Prop               | Type                | Description                   | Since |
| ------------------ | ------------------- | ----------------------------- | ----- |
| **distinctId**     | string              | The distinct ID of the user.  | 6.0.0 |
| **userProperties** | Record<string, any> | The person properties to set. | 6.0.0 |

#### IsFeatureEnabledResult[¶](#isfeatureenabledresult "Permanent link")

| Prop        | Type    | Description                                                                                       | Since |
| ----------- | ------- | ------------------------------------------------------------------------------------------------- | ----- |
| **enabled** | boolean | Whether the feature flag is enabled. If the feature flag does not exist, the value will be false. | 7.0.0 |

#### IsFeatureEnabledOptions[¶](#isfeatureenabledoptions "Permanent link")

| Prop    | Type   | Description                  | Since |
| ------- | ------ | ---------------------------- | ----- |
| **key** | string | The key of the feature flag. | 7.0.0 |

#### IsOptOutResult[¶](#isoptoutresult "Permanent link")

| Prop         | Type    | Description                                  | Since |
| ------------ | ------- | -------------------------------------------- | ----- |
| **optedOut** | boolean | Whether the user has opted out of capturing. | 8.1.0 |

#### RegisterOptions[¶](#registeroptions "Permanent link")

| Prop      | Type   | Description                      | Since |
| --------- | ------ | -------------------------------- | ----- |
| **key**   | string | The name of the super property.  | 6.0.0 |
| **value** | any    | The value of the super property. | 6.0.0 |

#### ScreenOptions[¶](#screenoptions "Permanent link")

| Prop            | Type                | Description                                   | Since |
| --------------- | ------------------- | --------------------------------------------- | ----- |
| **screenTitle** | string              | The name of the screen.                       | 6.0.0 |
| **properties**  | Record<string, any> | The properties to send with the screen event. | 6.0.0 |

#### SetupOptions[¶](#setupoptions "Permanent link")

| Prop                                  | Type                                          | Description                                                                                                                                                                                                                                                                             | Default                    | Since |
| ------------------------------------- | --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- | ----- |
| **apiKey**                            | string                                        | The API key of your PostHog project.                                                                                                                                                                                                                                                    | 6.0.0                      |       |
| **apiHost**                           | string                                        | The API host of your PostHog instance or reverse proxy. If both apiHost and host are provided, apiHost takes precedence.                                                                                                                                                                | 'https://us.i.posthog.com' | 8.3.0 |
| **host**                              | string                                        | The API host of your PostHog instance. Deprecated alias for apiHost.                                                                                                                                                                                                                    | 'https://us.i.posthog.com' | 6.0.0 |
| **uiHost**                            | string                                        | The PostHog UI host used when apiHost points to a reverse proxy. Only available on Web.                                                                                                                                                                                                 | 8.3.0                      |       |
| **cookielessMode**                    | 'always' \| 'on\_reject'                      | Cookieless tracking mode. - 'always': Always use cookieless tracking with server-side anonymous hash. - 'on\_reject': Normal tracking until optOut() is called, then switches to cookieless. Only available on Web. Requires cookieless mode to be enabled in PostHog project settings. | 8.1.0                      |       |
| **enableSessionReplay**               | boolean                                       | Whether to enable session recording automatically.                                                                                                                                                                                                                                      | false                      | 7.3.0 |
| **optOut**                            | boolean                                       | Whether to opt out of capturing by default. User must call optIn() to enable capturing.                                                                                                                                                                                                 | false                      | 8.1.0 |
| **sessionReplayConfig**               | [SessionReplayOptions](#sessionreplayoptions) | Session replay configuration options.                                                                                                                                                                                                                                                   | 7.3.0                      |       |
| **captureApplicationLifecycleEvents** | boolean                                       | Whether to capture application lifecycle events. Only available on iOS and Android.                                                                                                                                                                                                     | true                       | 8.3.0 |

#### SessionReplayOptions[¶](#sessionreplayoptions "Permanent link")

| Prop                        | Type    | Description                                                                                     | Default | Since |
| --------------------------- | ------- | ----------------------------------------------------------------------------------------------- | ------- | ----- |
| **screenshotMode**          | boolean | Enable screenshot mode for session recordings. WARNING: This may capture sensitive information. | false   | 7.3.0 |
| **maskAllTextInputs**       | boolean | Mask all text input fields in session recordings.                                               | true    | 7.3.0 |
| **maskAllImages**           | boolean | Mask all images in session recordings.                                                          | true    | 7.3.0 |
| **maskAllSandboxedViews**   | boolean | Mask all sandboxed system views (iOS-specific).                                                 | true    | 7.3.0 |
| **captureNetworkTelemetry** | boolean | Capture network telemetry in session recordings.                                                | false   | 7.3.0 |
| **debouncerDelay**          | number  | Debounce delay for session recording snapshots (in seconds).                                    | 1.0     | 7.3.0 |

#### UnregisterOptions[¶](#unregisteroptions "Permanent link")

| Prop    | Type   | Description                               | Since |
| ------- | ------ | ----------------------------------------- | ----- |
| **key** | string | The name of the super property to remove. | 6.0.0 |

### Type Aliases[¶](#type-aliases "Permanent link")

#### JsonType[¶](#jsontype "Permanent link")

`string | number | boolean | null | { [key: string]: [JsonType](#jsontype); } | JsonType[]`

## Advanced[¶](#advanced "Permanent link")

### Reverse Proxy[¶](#reverse-proxy "Permanent link")

For PostHog managed reverse proxy, set `apiHost` to your proxy URL and `uiHost` to your PostHog app host (`https://us.posthog.com` or `https://eu.posthog.com`). `host` remains supported as a deprecated alias for `apiHost`. `uiHost` is only available on Web.

## Changelog[¶](#changelog "Permanent link")

See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/posthog/CHANGELOG.md).

## License[¶](#license "Permanent link")

See [LICENSE](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/posthog/LICENSE).

---

1. This project is not affiliated with, endorsed by, sponsored by, or approved by PostHog, Inc. or any of their affiliates or subsidiaries. [↩](#fnref:1 "Jump back to footnote 1 in the text")

May 17, 2026 

 Back to top 