Send Events
Send events to Hardal with an HTTP POST to the /collect endpoint.
curl -X POST "https://analytics.yourdomain.com/collect" \
-H "Content-Type: application/json" \
-H "User-Agent: YOUR_CLIENT_USER_AGENT" \
-H "x-hrd-session-id: 123e4567-e89b-12d3-a456-426614174000" \
-H "x-hrd-consent: denied" \
-H "X-Forwarded-For: example_string" \
-d '{
"tenantId": "11111111-1111-4111-8111-111111111111",
"type": "event",
"eventName": "quote_requested",
"payload": {
"sourceId": "22222222-2222-4222-8222-222222222222",
"title": "Request a Quote",
"hostname": "www.yourdomain.com",
"url": "https://www.yourdomain.com/quote",
"timestamp": 1773914400000,
"data": {
"plan": "enterprise",
"seats": 250,
"region": "EMEA"
}
}
}'
import requests
import json
url = "https://analytics.yourdomain.com/collect"
headers = {
"Content-Type": "application/json",
"User-Agent": "YOUR_CLIENT_USER_AGENT",
"x-hrd-session-id": "123e4567-e89b-12d3-a456-426614174000",
"x-hrd-consent": "denied",
"X-Forwarded-For": "example_string"
}
data = {
"tenantId": "11111111-1111-4111-8111-111111111111",
"type": "event",
"eventName": "quote_requested",
"payload": {
"sourceId": "22222222-2222-4222-8222-222222222222",
"title": "Request a Quote",
"hostname": "www.yourdomain.com",
"url": "https://www.yourdomain.com/quote",
"timestamp": 1773914400000,
"data": {
"plan": "enterprise",
"seats": 250,
"region": "EMEA"
}
}
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://analytics.yourdomain.com/collect", {
method: "POST",
headers: {
"Content-Type": "application/json",
"User-Agent": "YOUR_CLIENT_USER_AGENT",
"x-hrd-session-id": "123e4567-e89b-12d3-a456-426614174000",
"x-hrd-consent": "denied",
"X-Forwarded-For": "example_string"
},
body: JSON.stringify({
"tenantId": "11111111-1111-4111-8111-111111111111",
"type": "event",
"eventName": "quote_requested",
"payload": {
"sourceId": "22222222-2222-4222-8222-222222222222",
"title": "Request a Quote",
"hostname": "www.yourdomain.com",
"url": "https://www.yourdomain.com/quote",
"timestamp": 1773914400000,
"data": {
"plan": "enterprise",
"seats": 250,
"region": "EMEA"
}
}
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"tenantId": "11111111-1111-4111-8111-111111111111",
"type": "event",
"eventName": "quote_requested",
"payload": {
"sourceId": "22222222-2222-4222-8222-222222222222",
"title": "Request a Quote",
"hostname": "www.yourdomain.com",
"url": "https://www.yourdomain.com/quote",
"timestamp": 1773914400000,
"data": {
"plan": "enterprise",
"seats": 250,
"region": "EMEA"
}
}
}`)
req, err := http.NewRequest("POST", "https://analytics.yourdomain.com/collect", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("User-Agent", "YOUR_CLIENT_USER_AGENT")
req.Header.Set("x-hrd-session-id", "123e4567-e89b-12d3-a456-426614174000")
req.Header.Set("x-hrd-consent", "denied")
req.Header.Set("X-Forwarded-For", "example_string")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://analytics.yourdomain.com/collect')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['User-Agent'] = 'YOUR_CLIENT_USER_AGENT'
request['x-hrd-session-id'] = '123e4567-e89b-12d3-a456-426614174000'
request['x-hrd-consent'] = 'denied'
request['X-Forwarded-For'] = 'example_string'
request.body = '{
"tenantId": "11111111-1111-4111-8111-111111111111",
"type": "event",
"eventName": "quote_requested",
"payload": {
"sourceId": "22222222-2222-4222-8222-222222222222",
"title": "Request a Quote",
"hostname": "www.yourdomain.com",
"url": "https://www.yourdomain.com/quote",
"timestamp": 1773914400000,
"data": {
"plan": "enterprise",
"seats": 250,
"region": "EMEA"
}
}
}'
response = http.request(request)
puts response.body
{
"success": true,
"data": {
"accepted": 1,
"events": [
{
"eventId": "44444444-4444-4444-8444-444444444444",
"sourceId": "22222222-2222-4222-8222-222222222222"
}
],
"consentStatus": "denied"
},
"timestamp": "2026-11-24T12:00:00.000Z",
"path": "/collect/",
"requestId": "33333333-3333-4333-8333-333333333333"
}
{
"success": true,
"data": {
"skipped": true,
"reason": "bot-request"
},
"timestamp": "2026-11-24T12:00:00.000Z",
"path": "/collect/",
"requestId": "33333333-3333-4333-8333-333333333333"
}
{
"success": false,
"error": {
"code": "invalid-collect-payload",
"message": "invalid-collect-payload",
"details": {
"formErrors": [],
"fieldErrors": {
"payload": [
"Invalid option: expected one of 25|50|75|90|100"
]
}
}
},
"timestamp": "2026-11-24T12:00:00.000Z",
"path": "/collect/",
"requestId": "33333333-3333-4333-8333-333333333333"
}
/collect
Target server for requests. Edit to use your own host.
The media type of the request body
Send the client or application's User-Agent. Requests with a missing, blank, or bot-like value can be skipped.
Optional UUID shared by events in the same session.
Consent state: granted or denied. For server integrations, send denied when consent is declined or unknown. See Consent Signals.
Original client IP from trusted request context when consent is granted. Hardal uses the first address for location. Omit the header if consent is declined or unknown, or if the client IP is unavailable.
Your Tenant ID from Setup in the Dashboard. Send it in the JSON body.
Optional session UUID. You can use x-hrd-session-id instead.
Consent state: granted or denied. You can use x-hrd-consent instead.
Use event for standard and custom actions, or page_view for a page visit.
The action name, such as purchase, quote_requested or page_view.
Send multiple events in this array instead of the single-event fields.
Request Preview
Response
Response will appear here after sending the request
Headers
Send the client or application's User-Agent. Requests with a missing, blank, or bot-like value can be skipped.
YOUR_CLIENT_USER_AGENTOptional UUID shared by events in the same session.
Consent state: granted or denied. For server integrations, send denied when consent is declined or unknown. See Consent Signals.
deniedgrantedOriginal client IP from trusted request context when consent is granted. Hardal uses the first address for location. Omit the header if consent is declined or unknown, or if the client IP is unavailable.
Body
Your Tenant ID from Setup in the Dashboard. Send it in the JSON body.
11111111-1111-4111-8111-111111111111Optional session UUID. You can use x-hrd-session-id instead.
33333333-3333-4333-8333-333333333333Consent state: granted or denied. You can use x-hrd-consent instead.
granteddeniedSend multiple events in this array instead of the single-event fields.
Responses
Send an event
Use your collection URL, Tenant ID, and Source ID from Setup in the Dashboard. For cURL, set USER_AGENT to the user agent of the actual sender. When forwarding a browser request, use the original browser user agent.
EVENT_TIME_MS=$(($(date +%s) * 1000))
curl --fail-with-body -X POST "https://analytics.yourdomain.com/collect" \
-H "Content-Type: application/json" \
-H "User-Agent: ${USER_AGENT:?Set USER_AGENT for the request}" \
-H "x-hrd-consent: denied" \
--data-binary @- <<JSON
{
"tenantId": "11111111-1111-4111-8111-111111111111",
"type": "event",
"eventName": "quote_requested",
"payload": {
"sourceId": "22222222-2222-4222-8222-222222222222",
"timestamp": $EVENT_TIME_MS,
"data": {
"plan": "enterprise"
}
}
}
JSON
Replace the example IDs with the values from your source. The example timestamps a new test event. For a queued or retried event, keep its original occurrence time in milliseconds.
Build the body
| Field | Required | What to send |
|---|---|---|
tenantId | Yes | Your Tenant ID (UUID), in the JSON body. |
type | Yes | Use event for standard and custom actions. For a page visit, use page_view. |
eventName | Yes | The action name, such as purchase, quote_requested, or page_view. |
payload.sourceId | Yes | Your Source ID (UUID). |
payload.timestamp | Yes | Event time as a Unix timestamp in milliseconds. |
payload.data | No | Parameters for the event, such as plan, value, or items. |
type describes the kind of event; eventName describes the action. Keep event parameters inside payload.data.
For page visits, include payload.url with its query parameters and payload.referrer when available. For purchases and other standard events, use the parameters in Standard Events. You can also send Custom Events.
To send several events together, use an events array with type, eventName, and payload in each entry. Keep tenantId at the top level.
Optional headers
x-hrd-session-id: a UUID shared by events in the same session.x-hrd-consent:grantedordenied. Senddeniedif consent is declined or unknown in a server integration. See Consent Signals.X-Forwarded-For: the original client IP from your trusted proxy or request context when consent is granted. Hardal uses the first IP in the header.
To link events to a known user, follow Identify Visitors.
Check the result
For this single event, expect HTTP 202 and data.accepted: 1. Check the returned event ID and confirm the event in Engagement → Events. If the response contains data.skipped: true, check that the request includes the client's or application's User-Agent.
For 400 Bad Request, read the response details. In addition to the required fields and UUIDs, check event-specific parameters:
| Event | Fields to check |
|---|---|
scroll_depth | Send a numeric payload.data.percent of 25, 50, 75, 90, or 100. |
outbound_click | Include the originating page's absolute payload.url, an absolute payload.data.linkUrl, and the matching hostname in payload.data.linkDomain. |
After correcting the request, verify the event in the Dashboard.