Track sale events

Endpoint

POST /api/track/sale

Track a sale conversion event for a short link. This endpoint creates a sale event and upserts a customer record.

Endpoint text
POST /api/track/sale

Authentication

Requires authentication with an API key that has the conversionsWrite scope.

Request Body

Accepts a single object (not an array). All fields are required unless marked optional.

ParameterTypeRequiredDescription
customerExternalId (body)stringYesCustomer external ID (1-100 characters). Used to upsert the customer.
amount (body)integerYesSale amount (non-negative integer).
currency (body)stringNoCurrency code. Defaults to "usd".
eventName (body)stringNoSale event name. Defaults to "Purchase" (max 255 characters).
metadata (body)objectNoOptional metadata object stored with the sale event.
leadEventName (body)stringNoLead event name to attribute this sale to a specific lead.
clickId (body)stringNoClick ID for direct sale attribution.
customerName (body)stringYesCustomer name (max 100 characters).
customerEmail (body)string (email)NoCustomer email. Optional. Can be null to clear.
customerAvatar (body)string (URL)NoCustomer avatar URL. Optional. Can be null to clear.

Capture clickId in the browser

If you want to attribute a sale directly to a click, use the Browser attribution script to persist `hoko_id` and pass it as clickId. See [Browser attribution script](/docs/track/analytics-js).

Attribution Priority

The sale is attributed in this order: leadEventName (if provided) → clickId (if provided) → most recent lead for the customer. If no lead exists and no clickId is provided, the request fails.