Create a custom goal

POST https://datafa.st/api/v1/goals

Create a custom goal for a specific visitor. Requires Bearer Token authentication.

Request body

Send a JSON object with the following fields:

  • datafast_visitor_id (String, required): The DataFast unique ID of the visitor. It is stored in the visitor's browser cookies, making it accessible in your backend API endpoints.
  • name (String, required): Name for the goal (lowercase letters, numbers, underscores, hyphens, max 32 chars).
  • metadata (Object, optional): Custom parameters to enrich your event data.

Custom parameters rules (in metadata object):

  • Property names: lowercase letters, numbers, underscores (_), and hyphens (-) only. Max 32 characters.
  • Property values: any string, max 255 characters. HTML and script content is automatically removed for security.
  • Limits: maximum 10 custom parameters per event.

A visitor needs to have at least one pageview before the goal can be created.

Response

  • Success (200 OK): Returns a confirmation message and the ID of the created event.
  • Errors: See API Introduction. A 400 occurs if the visitor is a bot. A 404 occurs if the visitor has no prior pageviews.
Something missing? Suggest features ✍️