With PostHog, your app can:
- Capture product analytics events with
posthog-jsusing a project token - Evaluate feature flags for users in the browser or from backend code
- Send events from server routes to the PostHog capture API
- Build product experiences on top of analytics and feature flags
phc_) for PostHog’s public capture and flags endpoints. Your app calls PostHog ingest hosts directly. It does not use Lovable’s connector gateway, and it does not accept personal API keys (phx_).
Common use cases and example apps
Use PostHog when your Lovable app needs product analytics, feature flags, or server-side event capture tied to a PostHog project.How to connect PostHog
Who can create PostHog connections depends on your plan and workspace settings. App + chat connectors are available by default on Free, Pro, and Business plans. On Enterprise plans, they are effectively disabled at first: Who can create connections and clients defaults to No one until an admin changes it in Connectors → Admin settings → App + chat connectors. You can create multiple PostHog connections using different projects or regions, which is useful for separating environments (for example, development and production). When the connection is created, you can link it to the projects where you want to use it. Anyone building in a project can ask Lovable in chat to link their project to it.Prerequisites
Before connecting PostHog, make sure you have:- A PostHog Cloud account and project
- The project’s numeric Project ID
- A project token that starts with
phc_ - The cloud region where the project is hosted (
euorus) - Permission to create connections in your Lovable workspace (see Who can create connections and clients)
Event capture, feature flags, and other PostHog usage count toward your PostHog plan. Billing and quota are handled directly by PostHog, not Lovable.
Step 1: Get your PostHog project details
You need three values from PostHog: region, project ID, and project token. To find them:1
Open your PostHog project
Sign in to PostHog (or your EU host if your project is on EU Cloud).
2
Open project settings
Go to Project settings.
3
Copy the project ID and project token
Copy the numeric Project ID and a Project API key / project token that starts with
phc_.4
Confirm your region
Note whether the project is on Europe (
eu.i.posthog.com) or the United States (us.i.posthog.com). See PostHog API base URL.Step 2: Connect PostHog to Lovable
You can create multiple connections using different PostHog projects or tokens.1
Open PostHog in Connectors
Open Connectors and select PostHog. For the other places to open the catalog from, see Where to find connectors.
2
Add a connection
Click Add connection.
3
Configure the connection
- Display name: name the connection, for example
PostHog Prod. This name is only used inside Lovable to identify the connection. - Region: select Europe (eu.i.posthog.com) or United States (us.i.posthog.com) to match where your PostHog project is hosted.
- Project ID: paste the numeric PostHog project ID from Project settings.
- Project token: paste the project token that starts with
phc_.
4
Choose who can use this connection
Under Who can use this connection, decide who in your workspace can use the connection. You start as the only person with access:
- Only you (default): leave the access list as is; only you can use the connection and its associated data.
- Invite specific people: add workspace members by email; only you and the people you add can use the connection and its associated data.
- Invite entire workspace: click Invite entire workspace to make the connection available to everyone in your Lovable workspace.
5
Connect
Click Connect. Lovable validates the project token against PostHog before saving the connection.
Limitations
The PostHog connector cannot:- Accept personal API keys (
phx_). Use a project token (phc_) only. - Proxy PostHog requests through Lovable’s connector gateway. Your app calls PostHog ingest hosts directly (
eu.i.posthog.comorus.i.posthog.com). - Cover PostHog private admin REST APIs that require a personal API key.
- Support per-end-user PostHog login. Each connection represents a single PostHog project shared across all projects linked to it.
Manage your connection
Connections are managed from Connectors: select , then open the connection.- Unlink projects to remove access from specific projects while keeping the connection available for others. See Unlink projects from a connection for the steps.
- Delete the connection to remove it from the workspace entirely. Deleting is permanent. It removes the credentials from all linked projects, and app features that use stop working until a new connection is added. See Delete a connection for the steps and who can delete.