n8n
Contents
Objective
Integrating PostHog with n8n for workflow automation.
Why is this useful?
n8n is an open source workflow automation tool that enables you to connect various services together. With the PostHog node in n8n, you can:
- Capture events in PostHog from any of n8n's 400+ integrations
- Create user identities and aliases
- Track page views and screen views
- Build automated workflows that sync data to PostHog
This is particularly useful for product teams who want to track events from tools that don't have native PostHog SDKs, or for creating complex automation workflows that involve analytics tracking.
Prerequisites
To follow this tutorial, you should:
- Have a PostHog account (Cloud or self-hosted)
- Have an n8n instance (Cloud or self-hosted)
Step-by-step instructions
Setting up PostHog credentials in n8n
- In your n8n instance, go to Settings > Credentials.
- Click Add Credential and search for PostHog.
- Select PostHog API from the list.
- Enter the following details:
- URL: Your PostHog instance URL
- PostHog Cloud US:
https://us.posthog.com - PostHog Cloud EU:
https://eu.posthog.com - Self-hosted: Your instance URL
- PostHog Cloud US:
- API Key: A PostHog Personal API Key
- URL: Your PostHog instance URL
- Click Save to store the credentials.

Creating a workflow with PostHog
- In n8n, click New Workflow to create a new workflow.
- Add a trigger node (e.g., Webhook, Schedule, or any app trigger).
- Click the + button to add a new node and search for PostHog.
- Select the PostHog node.
Configuring PostHog operations
The PostHog node supports the following operations:
Capture Event
Send a custom event to PostHog.
- Set Resource to Event.
- Set Operation to Create.
- Configure the fields:
- Event: Name of the event to track (required)
- Distinct ID: Enter a unique identifier for the user. You can map this from your trigger data (e.g., email address, user ID). This ID should uniquely identify a specific user - you'll be able to see all events from a single user inside PostHog.
- Do NOT use a hardcoded ID for all your events here. If these events don't belong to a user generate a random UUID.
- Additional Fields: Add any extra properties
- Properties: Custom event properties as key-value pairs
- Timestamp: Override the event timestamp
Example configuration:
| Field | Value |
|---|---|
| Distinct ID | {{ $json.email }} |
| Event | purchase_completed |
| Properties | {"amount": 99.99, "currency": "USD"} |

Create Alias
Link two distinct IDs together (useful for connecting anonymous users to identified users).
- Set Resource to Alias.
- Set Operation to Create.
- Configure the fields:
- Distinct ID: The new distinct ID
- Alias: The existing distinct ID to link
Create Identity
Create or update a user identity with properties.
- Set Resource to Identity.
- Set Operation to Create.
- Configure the fields:
- Distinct ID: Unique identifier for the user
- Additional Fields: Add user properties
- Properties: User properties as key-value pairs
Testing your workflow
- Click Test Workflow to execute the workflow.
- Verify events appear in your PostHog Activity tab.
- Once confirmed, activate the workflow by toggling it on.
FAQ
Where can I find out more?
Check PostHog's API documentation for more information on events and user properties. Further information about n8n's PostHog node is available in n8n's documentation.
Who maintains this integration?
This integration is maintained by n8n. If you have issues with the integration not functioning as intended please reach out to n8n.
What if I have feedback on this integration?
We love feature requests and feedback! Please tell us what you think!
Can I use this with a self-hosted PostHog instance?
Yes! Simply enter your self-hosted instance URL when configuring the PostHog credentials in n8n.
What if my question isn't answered above?
We love answering questions. Ask us anything via our community forum, or drop us a message.