PostHog
The PostHog integration is to all users signed up after September '23, the legacy Grow and Pro plans, and Enterprise plans. If you're on a legacy Free or Starter plan and want to access this integration, migrate to our new pricing via your billing settings.
PostHog can be a useful integration tool for seeing all events and revenue that occur for your app even if it’s not active for a period of time. You can use PostHog's product analytics to find patterns in customer behavior and inform marketing strategies.
With our PostHog integration, you can:
- Create a behavioral cohort of customers based on specific actions, such as watching a specific episode of a show after subscribing. Follow a cohort throughout their lifecycle to realize overarching trends.
- Measure the path of a user from marketing material to the purchase of a subscription.
With accurate and up-to-date subscription data in PostHog, you'll be set to turbocharge your product analytics ⚡️
Integration at a Glance
Includes Revenue | Supports Negative Revenue | Sends Sandbox Events | Includes Customer Attributes | Sends Transfer Events | Optional Event Types |
---|---|---|---|---|---|
✅ | ✅ | Requires API key | ✅ | ❌ | non_subscription_purchase_event uncancellation_event subscription_paused_event expiration_event billing_issue_event product_change_event |
Events
The PostHog integration tracks the following events:
Event | Default Event Name | Description | App Store | Play Store | Amazon | Stripe | Promo |
---|---|---|---|---|---|---|---|
Initial Purchase | rc_initial_purchase_event | A new subscription has been purchased. | ✅ | ✅ | ✅ | ✅ | ❌ |
Trial Started | rc_trial_started_event | The start of an auto-renewing subscription product free trial. | ✅ | ✅ | ✅ | ✅ | ❌ |
Trial Converted | rc_trial_converted_event | When an auto-renewing subscription product converts from a free trial to normal paid period. | ✅ | ✅ | ✅ | ✅ | ❌ |
Trial Cancelled | rc_trial_cancelled_event | When a user turns off renewals for an auto-renewing subscription product during a free trial period. | ✅ | ✅ | ✅ | ✅ | ❌ |
Renewal | rc_renewal_event | An existing subscription has been renewed or a lapsed user has resubscribed. | ✅ | ✅ | ✅ | ✅ | ❌ |
Cancellation | rc_cancellation_event | A subscription or non-renewing purchase has been cancelled. See cancellation reasons for more details. | ✅ | ✅ | ✅ | ✅ | ✅ |
Uncancellation | rc_uncancellation_event | A non-expired cancelled subscription has been re-enabled. | ✅ | ✅ | ✅ | ❌ | ❌ |
Non Subscription Purchase | rc_non_subscription_purchase_event | A customer has made a purchase that will not auto-renew. | ✅ | ✅ | ✅ | ✅ | ✅ |
Subscription Paused | rc_subscription_paused_event | A subscription has been paused. | ❌ | ✅ | ❌ | ❌ | ❌ |
Expiration | rc_expiration_event | A subscription has expired and access should be removed. If you have Platform Server Notifications configured, this event will occur as soon as we are notified (within seconds to minutes) of the expiration. If you do not have notifications configured, delays may be approximately 1 hour. | ✅ | ✅ | ✅ | ✅ | ✅ |
Billing Issues | rc_billing_issue_event | There has been a problem trying to charge the subscriber. This does not mean the subscription has expired. Can be safely ignored if listening to CANCELLATION event + cancel_reason=BILLING_ERROR. | ✅ | ✅ | ✅ | ✅ | ❌ |
Product Change | rc_product_change_event | A subscriber has changed the product of their subscription. This does not mean the new subscription is in effect immediately. See Managing Subscriptions for more details on updates, downgrades, and crossgrades. | ✅ | ✅ | ❌ | ✅ | ❌ |
For events that have revenue, such as trial conversions and renewals, RevenueCat will automatically record this amount along with the event in PostHog.
Setup
1. Set PostHog User Identity
In order to associate RevenueCat data with a PostHog User, the RevenueCat $posthogUserId
Attribute should be set in RevenueCat. If this field does not exist, RevenueCat will fallback to the RevenueCat app user ID. You can read more about PostHog user profiles in PostHog's Identifying users documentation.
2. Send RevenueCat Events to PostHog
After you've set up the Purchase SDK and PostHog SDK to have the same user identity, you can "turn on" the integration and configure the event names from the RevenueCat dashboard.
- Navigate to your app in the RevenueCat and find the Integrations card in the left menu. Select + New
- Choose PostHog from the Integrations menu
- Add your PostHog Project API key to the API key field in RevenueCat. The integration uses only public endpoints, so there is no need to set up personal API keys.
- Enter the event names that RevenueCat will send or choose the default event names
- Select whether you want sales reported as gross revenue (before app store commission), or after store commission and/or estimated taxes.
PostHog recommends having a production and sandbox project to separate live and testing environments. You can input both keys in the RevenueCat PostHog settings page.
Testing the PostHog integration
Make a sandbox purchase with a new user
Simulate a new user installing your app, and go through your app flow to complete the sandbox purchase.
Check that the PostHog event delivered successfully
While still on the Customer View, select the purchase event in the Customer History page and make sure that the PostHog integration event exists and was delivered successfully.
Check the PostHog dashboard for the delivered event
Navigate to your PostHog dashboard > People and groups. In the 'People & groups' tab, you will see the event's user created as a Person.
Navigate to your PostHog dashboard > Data management. In the 'Events' tab, you will see events RevenueCat has dispatched to PostHog.
Sample Events
Below are sample JSONs that are delivered to PostHog for events.
- Initial Purchase
- Trial Started
- Trial Converted
- Trial Cancelled
- Renewal
- Cancellation
- Uncancellation
{
"api_key": "<PostHog project API key>",
"distinct_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"timestamp": "2024-10-22T08:34:56.123412Z",
"event": "rc_initial_purchase_event",
"properties": {
"insert_id": "d1dca188-6a16-4109-b663-778c0dfe9124",
"currency": "USD",
"revenue": 29.99,
"product_id": "premium",
"subscriber_attributes": {},
"period_type": "NORMAL",
"purchased_at": "2024-10-22T08:34:56Z",
"expiration_at": "2024-11-22T08:34:56Z",
"entitlement_id": null,
"entitlement_ids": null,
"presented_offering_id": null,
"transaction_id": "1123142348431",
"original_transaction_id": "1123142348431",
"aliases": ["$RCAnonymousID:87c6049c58069238dce29853916d624c"],
"app_user_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"original_app_user_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"store": "APP_STORE",
"app_id": "appe2a3da5a50",
"platform": "iOS",
"rc_subscription_status": "active"
}
}
{
"api_key": "<PostHog project API key>",
"distinct_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"timestamp": "2024-10-22T08:34:56.123412Z",
"event": "rc_trial_started_event",
"properties": {
"insert_id": "d1dca188-6a16-4109-b663-778c0dfe9124",
"currency": "USD",
"revenue": 0.0,
"product_id": "rc_subscription_monthly",
"subscriber_attributes": {},
"period_type": "TRIAL",
"purchased_at": "2024-10-22T08:34:56Z",
"expiration_at": "2024-11-22T08:34:56Z",
"entitlement_id": null,
"entitlement_ids": [
"pro"
],
"presented_offering_id": null,
"transaction_id": "1123142348431",
"original_transaction_id": "1123142348431",
"aliases": ["$RCAnonymousID:87c6049c58069238dce29853916d624c"],
"app_user_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"original_app_user_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"store": "APP_STORE",
"app_id": "appe2a3da5a50",
"platform": "iOS",
"rc_subscription_status": "trial"
}
}
{
"api_key": "<PostHog project API key>",
"distinct_id": "123a4b56-7890-12cd-345e-67f90gh1ij1k",
"timestamp": "2024-10-22T08:34:56.123412Z",
"event": "rc_trial_converted_event",
"properties": {
"insert_id": "d1dca188-6a16-4109-b663-778c0dfe9124",
"currency": "USD",
"revenue": 19.99,
"product_id": "rc_3999_1y_1w0",
"subscriber_attributes": {
"$posthogUserId": "123a4b56-7890-12cd-345e-67f90gh1ij1k"
},
"period_type": "NORMAL",
"purchased_at": "2024-10-22T08:34:56Z",
"expiration_at": "2024-11-22T08:34:56Z",
"entitlement_id": null,
"entitlement_ids": [
"pro"
],
"presented_offering_id": null,
"transaction_id": "1123142348431",
"original_transaction_id": "1123142348431",
"aliases": ["$RCAnonymousID:87c6049c58069238dce29853916d624c"],
"app_user_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"original_app_user_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"store": "APP_STORE",
"app_id": "appe2a3da5a50",
"platform": "iOS",
"rc_subscription_status": "active"
}
}
{
"api_key": "<PostHog project API key>",
"distinct_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"timestamp": "2024-10-22T08:34:56.123412Z",
"event": "rc_trial_cancelled_event",
"properties": {
"insert_id": "d1dca188-6a16-4109-b663-778c0dfe9124",
"currency": "USD",
"revenue": 0.0,
"product_id": "premium",
"subscriber_attributes": {},
"period_type": "TRIAL",
"purchased_at": "2024-10-22T08:34:56Z",
"expiration_at": "2024-11-22T08:34:56Z",
"entitlement_id": null,
"entitlement_ids": null,
"presented_offering_id": null,
"transaction_id": "1123142348431",
"original_transaction_id": "1123142348431",
"aliases": ["$RCAnonymousID:87c6049c58069238dce29853916d624c"],
"app_user_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"original_app_user_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"store": "APP_STORE",
"app_id": "appe2a3da5a50",
"platform": "iOS",
"cancel_reason": "BILLING_ERROR",
"rc_subscription_status": "cancelled_trial"
}
}
{
"api_key": "<PostHog project API key>",
"distinct_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"timestamp": "2024-10-22T08:34:56.123412Z",
"event": "rc_renewal_event",
"properties": {
"insert_id": "d1dca188-6a16-4109-b663-778c0dfe9124",
"currency": "EUR",
"revenue": 29.99,
"product_id": "premium",
"subscriber_attributes": {},
"period_type": "NORMAL",
"purchased_at": "2024-10-22T08:34:56Z",
"expiration_at": "2024-11-22T08:34:56Z",
"entitlement_id": "pro",
"entitlement_ids": [
"pro"
],
"presented_offering_id": "standard",
"transaction_id": "1123142348431",
"original_transaction_id": "1123142348431",
"aliases": ["$RCAnonymousID:87c6049c58069238dce29853916d624c"],
"app_user_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"original_app_user_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"store": "APP_STORE",
"app_id": "appe2a3da5a50",
"platform": "iOS",
"rc_subscription_status": "active"
}
}
{
"api_key": "<PostHog project API key>",
"distinct_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"timestamp": "2024-10-22T08:34:56.123412Z",
"event": "rc_cancellation_event",
"properties": {
"insert_id": "d1dca188-6a16-4109-b663-778c0dfe9124",
"currency": "USD",
"revenue": 0.0,
"product_id": "premium",
"subscriber_attributes": {},
"period_type": "NORMAL",
"purchased_at": "2024-10-22T08:34:56Z",
"expiration_at": "2024-11-22T08:34:56Z",
"entitlement_id": null,
"entitlement_ids": null,
"presented_offering_id": null,
"transaction_id": "1123142348431",
"original_transaction_id": "1123142348431",
"aliases": ["$RCAnonymousID:87c6049c58069238dce29853916d624c"],
"app_user_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"original_app_user_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"store": "APP_STORE",
"app_id": "appe2a3da5a50",
"platform": "iOS",
"rc_subscription_status": "cancelled",
"cancel_reason": "BILLING_ERROR"
}
}
{
"api_key": "<PostHog project API key>",
"distinct_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"timestamp": "2024-10-22T08:34:56.123412Z",
"event": "rc_uncancellation_event",
"properties": {
"insert_id": "d1dca188-6a16-4109-b663-778c0dfe9124",
"currency": "USD",
"revenue": 0.0,
"product_id": "premium",
"subscriber_attributes": {},
"period_type": "NORMAL",
"purchased_at": "2024-10-22T08:34:56Z",
"expiration_at": "2024-11-22T08:34:56Z",
"entitlement_id": "pro",
"entitlement_ids": [
"pro"
],
"presented_offering_id": "subscription",
"transaction_id": "1123142348431",
"original_transaction_id": "1123142348431",
"aliases": ["$RCAnonymousID:87c6049c58069238dce29853916d624c"],
"app_user_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"original_app_user_id": "$RCAnonymousID:87c6049c58069238dce29853916d624c",
"store": "APP_STORE",
"app_id": "appe2a3da5a50",
"platform": "iOS",
"rc_subscription_status": "active"
}
}
Subscription Status Attribute
Whenever RevenueCat sends an event to PostHog, we'll update the rc_subscription_status
user attribute with any applicable changes, using one of the following values:
Status | Description |
---|---|
active | The customer has an active, paid subscription which is set to renew at their next renewal date. |
intro | The customer has an active, paid subscription through a paid introductory offer. |
cancelled | The customer has a paid subscription which is set to expire at their next renewal date. |
grace_period | The customer has a paid subscription which has entered a grace period after failing to renew successfully. |
trial | The customer is in a trial period which is set to convert to paid at the end of their trial period. |
cancelled_trial | The customer is in a trial period which is set to expire at the end of their trial period. |
grace_period_trial | The customer was in a trial period and has now entered a grace period after failing to renew successfully. |
expired | The customer's subscription has expired. |
promotional | The customer has access to an entitlement through a RevenueCat Granted Entitlement |
expired_promotional | The customer previously had access to an entitlement through a RevenueCat Granted Entitlement that has since expired. |
paused | The customer has a paid subscription which has been paused and is set to resume at some future date. |
For customers with multiple active subscriptions, this attribute will represent the status of only the subscription for which the most recent event occurred.
Please note that since this attribute is set and updated when events are delivered, subscribers with events prior to our release of this attribute (during November 2023) will not have this attribute set until/unless a future event (renewal, cancellation, etc) occurs.