# Goals

> Create goals for the actions you care about, test them, and read their completions on the Goals screen and the dashboard.

Source: https://supametrics.io/docs/goals

A goal is a conversion you care about: reaching a thank-you page, clicking a pricing button, finishing a
signup. Supametrics checks every visit against your goals as it arrives and records a **completion** each
time a goal's rule matches.

Goals count **from the moment you create or turn them on**. Earlier visits are never counted
retroactively, and a goal that is turned off counts nothing until you turn it back on.

## Where to manage goals

- The **Goals** screen at `/goals` (for example https://app.supametrics.io/goals): **Manage goals** in the left
  rail. You can also open it from the dashboard's Goals card (**+** › **Open the Goals page**, or **Create a
  goal**), or from a goal waiting for its first completion (**Set up this goal**).
- **Site settings › Dashboard**, which lists the same goals with the same **New goal** dialog.

Owners and members can create, edit, turn off and delete goals. Viewers see the goals read-only: the
switches are disabled and there is no **New goal**, edit or delete button. See
[Team members and roles](https://supametrics.io/docs/team-and-roles).

## Goal types

When you create a goal you pick what completes it under **Completes when**.

### URL path

Completes when a visitor views exactly that path.

- Enter the path only, starting with `/`, for example `/thank-you`. A path that doesn't start with `/` is
  rejected.
- The query string is ignored (`/thank-you?plan=pro` counts) and so is a trailing slash (`/thank-you/`
  counts).
- It's an exact, case-sensitive match: `/thank-you` does not match `/thank-you/team` or `/Thank-You`.
- In single-page apps, route changes count like page loads.

To count a group of pages (everything under `/docs/`, say), use a funnel page step with **Starts with** or
**Wildcard pattern** instead: see [Journeys and funnels](https://supametrics.io/docs/journeys-and-funnels).

### Element click

Completes when a visitor clicks an element matching a CSS selector, or anything inside it.

- Give the element an id or class you control, for example `<button id="signup-button">`, then use
  `#signup-button`.
- Any selector works: `.pricing a.cta`, `[data-plan="pro"] button`.
- The form checks that the selector is valid before saving.
- New or changed click goals reach visitors who already have your site open within a minute or two (the
  script refreshes its list of selectors about once a minute).

### JavaScript event

Completes when your own code reports the event. Enter the **Event name** (up to 64 characters, spaces and
punctuation allowed) exactly as your code sends it, then call:

```js
window.analyticsx?.('track', 'signup');
```

- The name must match exactly, including upper and lower case. Spaces at either end are ignored.
- Use the `?.` form so your page doesn't break if the script is blocked.
- Call it after the thing has actually happened, for example after your signup request succeeds.

After you save a JavaScript event goal, the dialog moves on to **One more step** and shows the exact line to
add, plus an HTML version for a button or link with no script of your own:

```html
<button onclick="window.analyticsx?.('track', 'signup')">
  Sign up
</button>
```

The goal never completes until your site sends the event. Until its first completion, the goal shows
**Waiting for your code to send** followed by the event name and the line to copy.

Sending goals from your server is not available yet: the **API** tab of the **Add goals** dialog is marked
**Soon**. Send them from the browser for now. More on the tracker calls in
[Tracker JavaScript API](https://supametrics.io/docs/tracker-javascript-api).

## Create a goal

1. Click **New goal** (on the Goals screen or in **Site settings › Dashboard**).
2. Enter a **Name** (up to 64 characters), for example `Signed up`. The name is what reports show.
3. Under **Completes when**, pick **URL path**, **Element click** or **JavaScript event**.
4. Fill in **Exact path**, **CSS selector** or **Event name** (up to 300 characters for paths and selectors,
   64 for event names).
5. Click **Create goal**.

A website can have up to **50 goals**. New goals are on straight away.

## Edit, turn off and delete

Each goal on the Goals screen has a switch, an edit button and a delete button.

- **Switch**: turns the goal off or on. A goal that is off shows an **Off** badge, keeps its past
  completions, and stops counting new ones.
- **Edit** opens **Edit goal**, where you can change the name, the type and the rule. If you change what an
  existing goal listens for, a warning says that the old rule stops counting and that its completions from
  the last 30 days stay with the goal. The new rule applies to visits from now on.
- **Delete** asks for confirmation. A deleted goal's completions drop out of every total and chart, alerts
  on that goal stop matching, and if it was your #1 KPI the dashboard goes back to revenue.

## The Goals screen

The Goals screen always covers the **last 30 days**, whatever date range the dashboard is set to.

- **Completions, 30 days**: every completion of every goal. A visitor who reaches `/thank-you` twice counts
  twice.
- **Converting visitors**: unique visitors who completed at least one goal.
- **Goal conversion rate**: converting visitors divided by all visitors in the same 30 days.
- **Goals running**: goals switched on out of all goals, with the time of the last completion.
- **Completions by day**: all goals together, per day.
- **Goal conversion**: one row per goal with its type, rule, last completion (time and page), and its
  **Completions**, **Visitors** (unique) and **Conversion rate** (the goal's visitors divided by all
  visitors).

## Test a goal

Do the action on your live site in a normal browser window, not one you excluded with `?ax_ignore=true`
(see [Exclusions](https://supametrics.io/docs/exclusions)). Within seconds the goal on the Goals screen shows **Last completed**
with the time and the page. That is the test result. The time refreshes at most once a minute, so a second
test right after the first may still show the earlier time while the completion itself is counted.

A goal that has never completed shows **Not completed yet. Trigger it on your site to test; it shows here
within seconds.** (or, for a JavaScript event goal, the line of code it is waiting for).

## Received but not a goal

When your site sends a custom event that no JavaScript event goal matches, its name is listed under
**Received but not a goal** on the Goals screen and in **Site settings › Dashboard**. Such events are not
counted anywhere until a goal matches them.

- Each name shows how many times it arrived and when it was last seen. The count is updated about once a
  minute.
- **Close to** points out a goal with a similar name, such as `sign_up` next to a goal for `signup`.
- **Create goal** opens **New goal** with the name filled in.
- **Use for "…" goal** edits the similar goal so it listens for this name instead (the dialog warns you
  before saving).
- Up to 50 names are kept per website. When the list is full, names not seen for 30 days make room for new
  ones. A name disappears from the list as soon as a goal (even a turned-off one) matches it.

## The Goals card on the dashboard

The dashboard's Goals card has four tabs: **Goal**, **Funnel**, **User** and **Journey**. It follows the
dashboard's date range and filters. See [The site dashboard](https://supametrics.io/docs/dashboard).

### Goal tab

- A line chart of completions over time, one line per visible goal (up to 8). Your KPI goal comes first,
  then the most completed.
- The goal list beside it shows each goal's completions in the period and the percentage of the period's
  unique visitors who completed it. **Search goals** narrows the list.
- **Goal visibility** (the sliders button, owners and members only) chooses which goals appear in the chart
  and list. A hidden goal is still tracked and counted everywhere else.
- **Add goals** (the **+** button) shows the JavaScript and HTML snippets and links to the Goals screen.
- Completions are counted in the period they happened in, for visits that match the dashboard filters.

### Goal details

Click a goal in the list to open its details:

- A sentence with its completions, the unique visitors who completed it, and their share of the period's
  visitors.
- **utm_content**: completions split by the visit's `utm_content` value (top 20), with `(none)` for visits
  without one.
- Actions:
  - **Edit** opens **Customize goal**: the **Tracking ID** (the rule, read-only here), **Name**,
    **Description** (up to 300 characters, shown in the details) and one of 18 **Colour** swatches. To change
    the rule itself, use **Edit** on the Goals screen.
  - **Hide** removes the goal from the chart and list (undo it in **Goal visibility**).
  - **Set as KPI** makes it the website's key goal: it is listed first, marked **KPI**, and becomes the #1 KPI
    on the dashboard. Only one goal can be the KPI goal; setting another one replaces it. The same choice is in
    **Site settings › General** under **#1 KPI**.
  - **Filter** filters the dashboard to visits that completed this goal.
  - **Funnel** opens the funnel builder with this goal as a step.
  - **Journey** opens the Journey tab for this goal.

Viewers see only **Filter** and **Journey**.

### Funnel, User and Journey tabs

- **Funnel** builds step-by-step funnels from page visits and goals. See
  [Journeys and funnels](https://supametrics.io/docs/journeys-and-funnels#funnels).
- **User** lists the period's visitors. See [Visitors and visitor profiles](https://supametrics.io/docs/visitors).
- **Journey** lists the visitors who completed one goal, with how long it took them. See
  [Journeys and funnels](https://supametrics.io/docs/journeys-and-funnels#goal-journey-tab).

## Goals elsewhere

- **Details › Goals** shows goal figures over any date range, including **Goal conversions** with revenue
  per goal. See [Details pages](https://supametrics.io/docs/details-pages).
- Goal completions can trigger alert emails. See [Email reports and alerts](https://supametrics.io/docs/reports-and-alerts).
- The **Visitors** screen lists which goals each visitor completed.

## Common questions

**Why didn't my old visits count?** Goals are checked when a visit arrives. A goal created today counts
from today.

**My event goal shows nothing.** Check **Received but not a goal**: a name that differs in case or spelling
(`Signup`, `sign_up`) shows up there. Then check that the call runs after the action and that the script
isn't blocked.

**Does one visitor count more than once?** Completions count every time; **Visitors** counts each person
once.
