# PostHog

The PostHog piece in ZBrain Flow provides integration with PostHog's product analytics platform. This connector enables you to create events and projects and interact with analytics data directly from your workflows. This piece is ideal for teams looking to enhance their analytics capabilities and maintain consistent data collection across their business processes.

### **How to Use PostHog in ZBrain Flow?** <a href="#how-to-use-posthog-in-zbrain-flow" id="how-to-use-posthog-in-zbrain-flow"></a>

**Step 1: Select PostHog as Your Connection**

* Click on the '+' button in the Flow and search for PostHog.
* Select PostHog.
* Decide on the action you need, then select it. ZBrain Flow provides several options:
  * **Create Event** – Create events in your PostHog instance.
  * **Create Project** – Set up new projects within PostHog.
  * **Custom API Call** – Make specialized requests to the PostHog API.

#### **How to Create Event** <a href="#how-to-create-event" id="how-to-create-event"></a>

**Step 1: Connect to PostHog**

* From the ‘Personal API Key' dropdown, click on ‘Create Connection.’
* A small window will appear where you need to enter:
  * A descriptive 'Connection Name'
  * Your 'Personal API Key' from your PostHog account
* Click 'Save' to create the connection.

**Step 2: Configure Event Details**

* In the 'Event name' field, enter a descriptive name for the action you want to create.
* From the 'Event type' dropdown, select the category that best describes this interaction.

**Step 3: Specify User Identification**

* In the 'Distinct Id' field, enter the unique identifier for the user performing this action. This could be a user ID, email, or another identifier.

**Step 4: Add Event Properties (Optional)**

* Click 'Add Item' in the 'Properties' section to include additional data points about the event. Each property consists of a key-value pair that provides context about the action.

**Step 5: Set Additional Context (Optional)**

* Click 'Add Item' in the 'Context' section to add environment information. This might include device details, location, or application state.

**Step 6: Configure Advanced Options (Optional)**

* In the 'Message ID' field, you can provide a unique identifier for deduplication.
* In the 'Category' field, you can add a higher-level grouping for the event.

#### **How to Create Project** <a href="#how-to-create-project" id="how-to-create-project"></a>

**Step 1: Connect to PostHog**

* To connect to your PostHog account, follow the first step in the "How to Create Event" section above.

**Step 2: Define Project Details**

* In the 'Name' field, enter a descriptive title for your new analytics project.

**Step 3: Configure Slack Integration (Optional)**

* In the 'Slack Incoming Webhook' field, enter a webhook URL if you want to receive notifications in Slack. This allows PostHog to send alerts and insights directly to your team.

**Step 4: Set Privacy Options**

* Toggle 'Anonymize IPs' if you want to mask user IP addresses for privacy compliance automatically.

**Step 5: Specify Project Type**

* Toggle 'Is demo project' if this is for testing or demonstration purposes. Demo projects may have different limitations or features than production projects.

#### **How to Make PostHog API Requests** <a href="#how-to-make-posthog-api-requests" id="how-to-make-posthog-api-requests"></a>

**Step 1: Connect to PostHog**

* To connect to your PostHog account, follow the first step in the "How to Create Event" section above.

**Step 2: Specify the API Endpoint**

* In the 'URL' field, enter the base PostHog URL with the endpoint you want to access.

**Step 3: Select Request Method**

* From the 'Method' dropdown, choose the appropriate HTTP method (GET, POST, etc.).

**Step 4: Add Custom Headers (Optional)**

* Click 'Add Item' in the 'Headers' section to add any special headers. Note that authorization headers are automatically included in your connection.

**Step 5: Configure Query Parameters (Optional)**

* Click 'Add Item' in the 'Query Parameters' section to add URL parameters.

**Step 6: Provide Request Body (Optional)**

* For POST, PUT, or PATCH requests, enter the JSON data to send. This contains the specific parameters for your API operation.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zbrain.ai/zbrain-documentation/zbrain-builder/flows/flow-components/posthog.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
