1. Overview
PostHog is an open-source product analytics platform that helps you understand user behavior, track events, and conduct A/B testing. It provides a comprehensive suite of tools for session recording, feature flags, and automated insights, all of which can be self-hosted for complete data control.
The GoInsight Posthog node allows you to integrate event tracking and user management directly into your automated workflows. You can send crucial data to your PostHog instance without writing any code, enabling you to capture key user interactions from various sources. Key capabilities include:
- Event Tracking: Create custom events to monitor user actions, such as sign-ups, purchases, or feature usage.
- User Identification: Identify users and update their properties to build a complete profile of their attributes and behavior.
- Alias Management: Link multiple user identities (e.g., an anonymous ID and an email) to a single user profile.
- Page and Screen Tracking: Log page views and screen views to analyze user navigation patterns in web and mobile applications.
2. Prerequisites
Before using this node, you must have a valid Posthog account, whether on PostHog Cloud or a self-hosted instance. You will need your Project API Key and your instance URL to configure the credentials in GoInsight.
3. Credentials
For a detailed guide on how to obtain and configure your credentials, please refer to our official documentation: Credentials Configuration Guide.
4. Supported Operations
Summary
This node provides operations centered around tracking events and managing user identities within PostHog. The table below summarizes the available actions.
| Resource | Operation | Description |
|---|---|---|
| Event | Create an Event | Create a custom event in PostHog by sending an event to the ingestion API. |
| Page View | Track a Page | Track a page view event for a user by sending a pageview event to PostHog ingestion API. |
| Screen View | Track a Screen | Tracks a screen view event in PostHog by sending a screen capture request to the PostHog capture API. |
| User Alias | Create an Alias | Create an alias for an existing user by sending a create alias event to PostHog ingestion API. |
| User Identity | Create an Identity | Identify a user or update user properties by sending a identify event to PostHog ingestion API. |
Operation Details
Create an Alias
Create an alias for an existing user by sending a create alias event to PostHog ingestion API.
Input Parameters:
- DistinctId: The original distinct ID of the user.
- AliasId: The new alias ID to assign.
Output:
- StatusCode (number): The result code returned by HTTP
- ErrorMessage (string): Error message returned by HTTP
Create an Event
Create a custom event in PostHog by sending an event to the ingestion API.
Input Parameters:
- DistinctId: The distinct ID of the user triggering the event.
- EventName: The name of the event to record.
Options:
- Properties: Additional properties for the event.
Output:
- StatusCode (number): Operation result code: -1: parameter validation error 200: request successful other HTTP status codes: corresponding failure status
- ErrorMessage (string): Error description if any, empty on success.
Create an Identity
Identify a user or update user properties by sending a identify event to PostHog ingestion API.
Input Parameters:
- DistinctId: The distinct ID of the user to identify.
Options:
- Properties: Optional user properties to set.
Output:
- StatusCode (number): Operation result code: -1: parameter validation error 200: request succeeded other HTTP status codes: corresponding failure status
- ErrorMessage (string): Error description if any, empty on success.
Track a Page
Track a page view event for a user by sending a pageview event to PostHog ingestion API.
Input Parameters:
- DistinctId: The distinct ID of the user viewing the page.
- PageUrl: The URL of the page being tracked.
- PageName: Optional page name.
Options:
- Properties: Optional additional properties to include with the event.
Output:
- StatusCode (number): Operation result code: -1 for parameter validation error, 200 for success, other HTTP status codes for failures.
- ErrorMessage (string): Error description if any, empty on success.
Track a Screen
Tracks a screen view event in PostHog by sending a screen capture request to the PostHog capture API.
Input Parameters:
- DistinctId: The distinct ID of the user viewing the screen.
- ScreenViewName: The name of the screen to track.
Options:
- Properties: Optional additional properties to include with the event.
Output:
- StatusCode (number): Operation result code: -1 parameter verification error, 200 successful, other HTTP status codes are failed.
- ErrorMessage (string): Error description, empty when successful.
5. Example Usage
This section will guide you through creating a simple workflow to track a "User Signed Up" event in PostHog whenever a new user is registered in your system.
The workflow will consist of a Start node, a Posthog: Create an Event node, and an Answer node.
- Add the Posthog Node
- In the workflow canvas, click the + button to add a new node.
- Select the "Tools" tab in the pop-up panel.
- Find and select "Posthog" from the list of tools.
- From the list of supported operations for Posthog, click on "Create an Event" to add the node to your canvas.
- Configure the Node
- Click on the newly added "Create an Event" node to open its configuration panel on the right.
- Credentials: In the "Credentials" field, select your pre-configured Posthog credential.
- Parameters: Fill in the input parameters for the event.
- DistinctId: This is the unique identifier for the user. You can map this from a previous node's output, for example, {{start.user_id}}. For this example, you can enter a test ID like user-12345.
- EventName: Enter the name of the event you want to track. For this scenario, type User Signed Up.
- Properties (Optional): This field accepts a JSON object for any additional data you want to associate with the event. For instance, you could track the user's subscription plan: {"plan": "premium", "source": "web_form"}.
- Run and Validate
- Once all required parameters are filled, any error indicators on the workflow should disappear.
- Click the "Test Run" button in the top-right corner of the canvas to execute the workflow.
- After the run completes successfully, you can click the logs icon to view the detailed input and output of the node. Check the StatusCode in the output; a value of 200 indicates that the event was successfully sent to PostHog.
After completing these steps, your workflow is fully configured. Every time it runs, it will send a "User Signed Up" event to your PostHog project, allowing you to analyze new user acquisition and behavior.
6. FAQs
Q: What is a DistinctId and why is it important?
A: The DistinctId is a unique identifier for a user in PostHog. It is crucial for correctly attributing events to users and building accurate user profiles. This ID should be consistent for a user across all their sessions and events. It could be a user ID from your database, an email address, or a randomly generated UUID.
Q: My events are not appearing in PostHog. What should I check?
A: If your events are not showing up, please verify the following:
- Credentials: Double-check that your Project API Key and PostHog Instance URL are correctly configured in your GoInsight credential.
- Node Output: Run the workflow and inspect the output of the Posthog node. Look for the StatusCode and ErrorMessage. A StatusCode other than 200 or a non-empty ErrorMessage will indicate a problem with the request.
- Data Ingestion Delay: There can sometimes be a slight delay before events appear in the PostHog UI. Please wait a few minutes and refresh.
- Ad Blockers: If you are testing on a browser, ensure that ad blockers or privacy extensions are not blocking requests to the PostHog API.
7. Official Documentation
For more in-depth information about the PostHog API and its features, please refer to the official documentation.
Leave a Reply.