The Firstparty Event HTTP API is the lowest-level way of sending Events to Firstparty. SDKs, including Firstparty.js, rely on the HTTP API as their method of sending data to Firstparty.
This HTTP Source is useful when you want to send data directly to Firstparty without relying on an existing library or when a library in your language doesn't exist. It's also helpful for debugging, testing, and prototyping new integrations.
The Firstparty Event collection API has only two endpoints:
/events/track for sending a single Event, and
/events/track/bulk for sending multiple Events in one payload. This may be different from what you've seen with other analytics or measurement providers, and is designed to make data collection flexible and customizable for anyone to configure at any time, rather than always requiring updates to code to make data collection changes.
In order to collect Events with the HTTP Source, your client will make HTTP requests to the Domain you've configured for your Source.
For example, if the Domain you've configured is
fp.rosebudmotels.com you'll make an HTTP POST request to
fp.rosebudmotels.com/events/track to collect a new Event.
No authentication is required to collect Events with the HTTP API (unlike most other requests to the Firstparty API).
content-typeheader must be set to 'application/json'.
- A Write Key is required to be sent with every Event (more below).
Every request to the
/events/track endpoint will result in a
200 OK response. To debug your requests, use the Debugger tab within the Source you're sending data to in the Firstparty UI.
The HTTP API Source only collects Events via the
Track a Single Event
To send a single Event to Firstparty, make an HTTP POST request to
/events/track that meets the requirements above, along with a JSON object with the keys outlined below as necessary.
"event": "Form Completed",
"name": "Stevie Budd"
track endpoint accepts a JSON object with these fields:
|The required name of the Event to collect
|The ID of the Profile generating the Event. If no Profile ID is provided, Firstparty will create a new Profile and return the new Profile ID in the HTTP response.
|The ID of the Session associated with the Event. If a Session ID is not provided, Firstparty may create a new Session and return the new Session ID in the HTTP response, depending on your Firstparty configuration.
|An optional key-value object of Properties to collect along with the Event. If the Event name was "Form Completed", one property may be "email_address"
|An optional key-value object of context to describe where the Event was generated. Read more about Context on the Event docs.