Source: https://datafa.st/docs/api/website/goals
Markdown source: https://datafa.st/docs/api/website/goals.md
Description: Analyze, create, and delete custom goal events.

# Goals API

Use the Goals API to analyze custom goal performance and send server-side goal events.

| Endpoint | Method | Path | Purpose |
|---|---|---|---|
| [Analyze goals](/docs/api/website/goals/analyze) | GET | `/api/v1/analytics/goals` | Analyze custom goal completions and visitors |
| [Create goal](/docs/api/website/goals/create) | POST | `/api/v1/goals` | Create a custom goal event for a visitor |
| [Delete goals](/docs/api/website/goals/delete) | DELETE | `/api/v1/goals` | Delete goal events by visitor, name, or date range |

## Code examples

### Create a goal

```bash
curl -X POST "https://datafa.st/api/v1/goals" \
  -H "Authorization: Bearer df_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "datafast_visitor_id": "visitor-id-from-cookie",
    "name": "newsletter_signup",
    "metadata": {
      "email": "user@example.com"
    }
  }'
```

### Success response

```json
{
  "status": "success",
  "data": [
    {
      "message": "Goal created successfully",
      "name": "newsletter_signup"
    }
  ]
}
```
