# Track goals

> Track sign-ups, demo requests, checkouts and other key actions as goals in Revfaro, with HTML data attributes, JavaScript or the server-side Goals API.

**In short:** A goal is an action you name, such as `signup` or `demo_request`. Add `data-rf-goal="signup"` to a button and every click is recorded, or call `window.revfaro('goal', 'signup')` from your code, or send goals from your server with the Goals API. Goals show which sources convert, power funnels and alerts, and count toward your monthly events.

## Track a click with an HTML attribute

Add `data-rf-goal` to any button, link or other clickable element. Every click records a goal with that name:

```html
<button data-rf-goal="signup_click">Sign up</button> <a href="/demo" data-rf-goal="demo_request">Book a demo</a>
```

Add details with more attributes that start with `data-rf-goal-`. Each one becomes a property of the goal:

```html
<button data-rf-goal="checkout_click" data-rf-goal-plan="pro" data-rf-goal-interval="yearly">Buy Pro</button>
<!-- recorded as checkout_click with { plan: "pro", interval: "yearly" } -->
```

## Track a goal from JavaScript

For actions that aren't a click, such as a completed form or a finished onboarding, call `window.revfaro` from your code:

```js
window.revfaro('goal', 'signup');
window.revfaro('goal', 'signup', { plan: 'pro', source: 'pricing_page' });
```

Use optional chaining (`window.revfaro?.('goal', 'signup')`) so your page never breaks when an ad blocker stops the script. If your code can run before the script has loaded, add the [queue snippet](https://revfaro.com/docs/install/#call-revfaro-before-the-script-has-loaded) first.

## Track a goal with the npm SDK

Using the [npm SDK](https://revfaro.com/docs/javascript-sdk/)? Call the shared tracker instance instead of the script global:

```ts
tracker.goal('signup', { plan: 'pro', source: 'pricing_page' });
```

The same `data-rf-goal` HTML attributes work with either installation method. `tracker.track()` is an
alias for `tracker.goal()`; do not send both for the same action.

## Track a goal from your server

Some actions only happen on your server: an account is activated, a trial starts, an invoice is paid. Send them with the Goals API and your website's API key. This needs a plan with API access.

```bash
curl -X POST https://revfaro.com/api/v1/goals \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"visitor_id":"<the rf_vid cookie>","name":"account_activated","props":{"plan":"pro"}}'
```

- `visitor_id` (required) is the value of the visitor's `rf_vid` cookie, which your server receives with every request from your own domain.
- `name` (required) is the goal name, up to 64 characters. `props` is optional.
- The goal is added to the visitor's latest visit. A visitor Revfaro has never seen returns `404`.

Find the API key in the **Setup** tab under **Connect payments › Other / API**. See [API reference](https://revfaro.com/docs/api/) for authentication.

## See your goals

Goals appear on the dashboard in the **Goals** tab, next to Funnel, Users and Journey:

| Column          | Meaning                                              |
| --------------- | ---------------------------------------------------- |
| **Visitors**    | Visitors who completed the goal at least once        |
| **Completions** | Every time the goal was completed                    |
| **Conversion**  | Share of all visitors in the period who completed it |
| **Revenue**     | Revenue from the visitors who completed it           |

Click a goal to filter the whole dashboard to the visitors who completed it, and see which channels, pages and countries they came from. The **Track goals** step in **Website settings › Setup** turns green once a goal was completed in the last 30 days.

![The Goals tab with visitors, completions, conversion and revenue per goal](https://revfaro.com/docs/img/panel-goals.webp 'Dashboard › Goals.')

## Good to know

- Goal names are cut at 64 characters, and property values from HTML attributes at 255 characters.
- `window.revfaro('track', 'name')` is the same as `window.revfaro('goal', 'name')`.
- Name your buy button's goal with `checkout`, `buy` or `purchase` in it (for example `checkout_click`). When a payment arrives without any other way to find its buyer, Revfaro looks at who clicked a checkout link or completed such a goal just before. See [how payments are matched](https://revfaro.com/docs/revenue-attribution/#how-are-payments-matched-to-visitors).
- Goals can trigger [email alerts](https://revfaro.com/docs/goal-alerts/) and be steps in [funnels](https://revfaro.com/docs/funnels/).

## Frequently asked questions

### How do I track a button click in Revfaro?

Add `data-rf-goal="your_goal_name"` to the button or link, for example `<button data-rf-goal="signup_click">Sign up</button>`. No JavaScript is needed.

### How should I name goals?

Use short, lower-case names with underscores, such as `signup`, `demo_request` or `checkout_click`, up to 64 characters. Use the same name everywhere the same action can happen.

### Do goals count toward my monthly events?

Yes. Each goal completion is one event, whether it comes from the script or the Goals API.

---

Source: https://revfaro.com/docs/goals/ · Last updated 2026-11-01
