Source: https://usedataowl.com/docs/custom-goals
Markdown source: https://usedataowl.com/docs/custom-goals.md
Description: Track signups, checkouts, button clicks, and custom conversion events using data attributes or a single JavaScript function call with custom properties.

# How to Track Custom Events & Conversion Goals

A goal is any action you want to count: a signup, a checkout, a download. Goals show on the overview with completions, unique visitors and conversion rate.

## From JavaScript

```js
// After the action succeeds
window.datasense?.("signup", { plan: "pro" })

window.datasense?.("download", { file: "pricing.pdf", size: 120 })
```

The optional chaining (`?.`) keeps your code working when an ad blocker stopped the script.

## From HTML

Add `data-ds-goal` to any element. Clicks on it, or on anything inside it, record the goal. Every `data-ds-goal-*` attribute becomes a property:

```html
<button data-ds-goal="checkout" data-ds-goal-plan="pro">Buy Pro</button>
```

## Before the script loads

Calls made before the script loads are queued if you add this stub first:

```html
<script>
  window.datasense = window.datasense || function () {
    (window.datasense.q = window.datasense.q || []).push(arguments)
  }
</script>
```

## Rules

- Goal names: up to 64 characters.
- Up to 10 properties per goal. Values must be strings, numbers or booleans; strings are cut at 255 characters.
- Goals count toward your monthly events, like pageviews.

## Where goals show up

- The **Goals** card on the overview, with conversion rate.
- The **Realtime** feed, as they happen.
- Each visitor's timeline on the **Visitors** page.
- The [goals endpoint](/docs/api/website/goals) and the `datasense_analytics_goals_breakdown` [MCP tool](/docs/mcp-tools).
