Getting Started:
To get started, make sure that both the PostHog tracking script and the Mida script are installed and loaded on the same page. This allows Mida to listen to events that PostHog sends in the browser and sync them in real time. The PostHog script should be initialized before any events you want to track are fired, and the Mida script should be loaded early in the page (preferably in the <head>) so it can reliably capture those events and make them available as goals or secondary goals in your experiments.
Additionally, make sure you’ve gone to the Integrations page in your Mida dashboard and enabled the PostHog connection. The integration must be active for Mida to start receiving events from PostHog and make them available for use as goals or secondary goals in your experiments.
Important steps
Before sending any custom events from PostHog to Mida, you need to retrieve the current visitor’s Mida UUID. This unique identifier lets you link PostHog events to the exact user and variant assignment inside Mida, so the events can be correctly used as goals or secondary goals in your experiments.
Here is a simple, framework-agnostic example to fetch the UUID once the Mida script is loaded:
<script>
function captureWithMidaUUID(eventName, properties) {
if (window.mida && typeof window.mida.uuid === 'function') {
window.mida.uuid()
.then(function (uuid) {
posthog.capture(eventName, {
...properties,
mida_uuid: uuid
});
})
.catch(function () {
// Fallback: send event without UUID
posthog.capture(eventName, properties);
});
} else {
// Mida not loaded yet
posthog.capture(eventName, properties);
}
}
// Example usage
captureWithMidaUUID('button_clicked', {
button_name: 'Start Free Trial'
});
</script>
This approach:
Fetches the Mida UUID once the script is available
Attaches it to the PostHog event as
mida_uuidAllows Mida to associate the event with the correct user and experiment variant
Falls back gracefully if the UUID is not yet available
Verify if the mida_uuid is being sent to PostHog:
Setting up the HTTP Webhook from Posthog Data Pipelines:
Once you have the mida_uuid verified, navigate to:
Then click the new button on the right side of the page and selection destination
Search for "HTTP Webhook" and click create:
Setup the HTTP Webhook (for more information, please scroll to the very bottom):
Debugging & Verifying events are successfully sent:
Some logs will show Failure status due to duplicated record indentified in Mida
Successful events that meet the criteria will be sent to the Mida Dashboard Events page.
Lastly, navigate back to your Mida App and verify that the events are being sent to Mida:
Final Notes
Once everything is set up, your PostHog events will flow into Mida in near real time and can be used as goals or secondary goals for your experiments and personalization campaigns.
To recap, make sure that:
PostHog and Mida scripts are both loaded on your site
The PostHog integration is enabled in the Mida Integrations page
The
mida_uuidis attached to your PostHog eventsYour HTTP Webhook is correctly configured and sending events successfully.
If you run into any issues or need help validating your setup, our support team is happy to help.
Webhook Endpoint Documentation
https://{region}.mida.so/abtest/event/webhook
Region: api-us or api-eu based on where your data was hosted
Method
POST
Description
This endpoint lets you record offline events (e.g. in-store purchases, phone signups, CRM activities) tied to specific users tracked by Mida.
User Identification
At least one of the following identification parameters is required:
Parameter | Type | Required | Description |
mida_uuid | String | Optional* | The unique identifier generated by Mida. Can be accessed using JavaScript: await mida.uuid() |
id | String | Optional* | Your system's user ID, set through Mida Client Side user attribution API |
String | Optional* | User's email address, set through Mida Client Side user attribution API |
At least one of these three parameters must be provided
Request Parameters
Parameter | Type | Required | Description |
project_key | String | Yes | The project key from Mida |
event_name | String | Yes | Name of the offline event (e.g. |
properties | Object | No | Optional metadata or custom properties related to the event |
Request Example
{
"project_key": "YOUR_PROJECT_KEY",
"event_name": "offline_purchase",
"mida_uuid": "85a35aca4df9",
"properties": {
"location": "Bangkok Store",
"amount": 199.99,
"agent": "John"
}
}
Response Codes
Status Code | Description |
200 | Event recorded successfully |
400 | Missing fields, invalid input, or visitor not found |
500 | Internal server error |
Response Examples
Successful Response (200)
{ "message": "Event recorded successfully" }Error Response (400)
{ "error": "Missing required fields: key, event_name, and at least one identifier (mida_uuid, email, or id)" }Error Response (400 - Visitor Not Found)
{ "error": "Visitor not found" }Usage Notes
This is for recording events that happen outside your website/app.
You'll need the
project keyfrom your Mida project. You can find it in the Mida dashboard.User identifiers (
mida_uuid,id, oremail) must already be known to Mida via previous attribution.Use the
propertiesfield to enrich events with custom details (like location, amount, agent, etc.).These events will be tied to the user’s session and show up in your Mida reports.
Example cURL Request
curl -X POST https://api-us.mida.so/abtest/event/webhook \
-H "Content-Type: application/json" \
-d '{
"project_key": "abc123widgetkey",
"event_name": "offline_purchase",
"email": "[email protected]",
"properties": {
"location": "Bangkok Store",
"amount": 199.99,
"agent": "John"
}
}'









