Skip to main content

Create Event

POST/v2/project/{project_key}/event

Create a new custom event for the selected project. Events track specific user actions and can be used as conversion goals in experiments.

Required body fields

FieldTypeDescription
event_textstringThe event name. Should be descriptive and consistent (e.g., "Signup Started", "Checkout Completed").

Optional fields

FieldTypeDescription
event_propertyobject or stringArbitrary key/value metadata to attach to the event. Pass as an object — it will be stored as JSON.
urlstringThe page URL where the event occurs.
event_pathstringThe URL path (e.g., /pricing).
sessionstringSession identifier if tracking within a specific session.

Example

curl -X POST "https://api-{region}.mida.so/v2/project/YOUR_PROJECT_KEY/event" \
-H "Authorization: Bearer YOUR_GENERATED_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"event_text": "Pricing CTA Clicked",
"event_property": {"button_id": "hero-cta", "placement": "above-fold"},
"url": "https://example.com/pricing"
}'

Success response

{
"success": true,
"event_id": 9876,
"event_text": "Pricing CTA Clicked",
"script": "<script type=\"text/javascript\">\n window.mdq = window.mdq || [];\n window.mdq.push([\"track\", \"Pricing CTA Clicked\"]);\n</script>",
"company_id": 1001
}

Response fields

FieldTypeDescription
event_idintegerThe newly created event's ID
event_textstringThe event name as stored
scriptstringReady-to-use tracking snippet for your website
company_idintegerYour company ID
Use the tracking snippet

The script field in the response contains a ready-to-use JavaScript snippet you can add to your website to fire this event from client-side code. Copy it directly into your page or tag manager.

Error responses

StatusMeaning
400Missing event_text or invalid field values
401Invalid or missing API key
Next step

To use this event as a conversion goal in an experiment, create a goal with goal_type: "script" and set goal_value to the event name (e.g. "Pricing CTA Clicked"). See Create Goal.