Create a custom goal
POST https://datafa.st/api/v1/goalsRecord a server-side custom goal event for a visitor. This is the recommended way to track signups, feature usage, and other backend-confirmed actions — more reliable than client-side tracking alone. See custom goals for naming conventions and dashboard setup.
Goal names are lowercased and spaces become underscores. The name
identify is reserved.Related: Custom goals · Journey tracking
Request
Query parameters
websiteIdstring
Required with a
dft_ account token on Website API routes. Omit with a df_ website key. Example: ?websiteId=665f0b3c4d2e1a0012345678.Body parameters
datafast_visitor_idstring
required
Visitor UUID from the
datafast_visitor_id cookie or tracking script. Example: "a3ab2331-989f-4cfa-91c6-2461c9e3c6bd". Alias: visitorId on some endpoints.visitorIdstring
Alias for
datafast_visitor_id on endpoints that accept both names.namestring
required
Goal name stored lowercase; spaces →
_. Allowed: a-z, 0-9, _, -, :. Max 64 chars. Reserved: identify. Example: "newsletter_signup". See custom goals.descriptionstring
Optional description stored with the event. Example:
"Newsletter form submit".metadataobject
Optional goal custom properties stored with the event. These are the same custom properties shown in the Goals dashboard side panel. Max 10 keys; keys
^[a-z0-9_-]+$ (max 64); values max 255 chars. Example: {"plan": "pro", "source": "api"}.Example request body
{
"datafast_visitor_id": "a3ab2331-989f-4cfa-91c6-2461c9e3c6bd",
"name": "newsletter_signup",
"metadata": { "plan": "pro" }
}
Response
Returns a JSON object with
status: "success" and endpoint-specific fields in data (and pagination when the endpoint is paginated).Response fields
statusstring
success.data[].messagestring
Human-readable confirmation or status message for the operation.
data[].eventIdstring
ObjectId of the event created by DataFast.
Authentication
df_website API key: The website is inferred from the key. You do not need awebsiteIdquery parameter.dft_account token: Requiresgoals:writepermission and?websiteId=on every request. The token must be allowed to access that website.
Read authentication and scopes for token creation, permission lists, and scoped tokens.
Errors
400 — Missing fields, invalid goal name format, reserved name, invalid metadata, or invalid JSON body.
403 — Tracking suspended for this website.
404 — Visitor has no pageviews on this website.
See API errors for the standard error envelope, auth failures, validation errors, permission errors, and rate limits.