Skip to content

Custom goals

View as Markdown

Track signups, clicks and other actions with JavaScript or HTML attributes.

On this page

A goal is a named action, such as signup, start_trial or checkout. Goals appear in your dashboard next to the channels and pages that led to them, and you can use them as funnel steps.

Goal names are lowercase letters, digits, _, - and :, up to 64 characters. Use : to group related goals, such as checkout:started and checkout:paid. Other characters are turned into _, so Sign Up becomes sign_up. Names starting with billing: are reserved for the built-in subscription goals.

Every command and method of the script is listed in the JavaScript API.

From JavaScript

js
reveata('goal', 'signup');

// With custom properties (string values, up to 20 keys)
reveata('goal', 'checkout', { plan: 'pro', billing: 'yearly' });

Call it after the script has loaded, or add the queue snippet so earlier calls are kept.

From HTML, without JavaScript

Add data-reveata-goal to any element. A click on it (or anything inside it) records the goal:

html
<button data-reveata-goal="signup">Create account</button>

Add properties with data-reveata-goal-<name> attributes. Dashes in the name become underscores:

html
<a href="/pricing" data-reveata-goal="view_pricing" data-reveata-goal-from-page="home">
  See pricing
</a>

When an element scrolls into view

Use data-reveata-scroll to record a goal the first time at least half of an element is visible:

html
<section data-reveata-scroll="saw_testimonials">…</section>

With the extras script below, scroll goals also take a visible share (data-reveata-scroll-threshold="0.8"), a time it must stay visible (data-reveata-scroll-delay="1500", in milliseconds) and properties (data-reveata-scroll-<name>). See scroll goals.

Automatic events

Without any setup the script also records:

  • Scroll depth and time on page: when a visitor leaves a page (or switches tab), the script reports how long the page was visible and, once they scrolled past the first screen, the deepest point they reached (from 25% up). See both in Pages → Page → Details: the average deepest scroll, the share of visits that reached 25%, 50%, 75% and the bottom of each page, and the average time on page (hover a page on the card for the same numbers). The API returns them with dimension=page&engagement=true on the breakdown. Turn scroll depth off with data-scroll="false".
  • Outbound links: clicks on links to other websites. Turn off with data-outbound="false".

A form with data-reveata-goal counts its goal when it is submitted, not when something inside it is clicked. Buttons and links count on click.

Automatic goals (opt-in)

Four more features are in a second, small script. Add it next to the tracking script and turn on what you need:

html
<script defer src="https://reveata.com/js/script.extras.js"
  data-track-404 data-downloads data-forms data-vitals></script>
  • Broken links (404): data-track-404 sends the built-in 404 goal when a page is answered with HTTP 404 (in browsers that report the status). Without the attribute, any page that contains <meta name="reveata:404"> or an element with data-reveata-404 sends it, which also works for single-page apps that show a not-found view. The goal carries the path and the address of the page that linked to it, both without query strings. The dashboard lists them in the Broken links (404) card with hits, visitors and the top referrer. With Next.js, render <ReveataNotFound /> in app/not-found.tsx instead.
  • File downloads: data-downloads sends file_download with the file's address (no query string) when someone clicks a link to a file: pdf, zip, dmg, exe, csv, xlsx, docx, pptx, mp3, mp4 and other common types, on your site or elsewhere, and any link with a download attribute. Give your own list instead: data-downloads="pdf,epub".
  • Form submissions: data-forms sends form_submit with the form's id (or name) and the path it posts to. What people type is never read or sent.
  • Web vitals: data-vitals measures LCP, INP, CLS, TTFB and FCP and sends them once per page when it is hidden or left. They are not goals: see them in Retention, paths and speed → Speed (75th percentile per metric and per page).

These goals show up in Goals like any other, named Broken link (404), File download and Form submit; rename them there if you like.

Reveata also writes subscription goals (trial started, paid, renewed, cancelled…) from your payment provider.

Pageviews with properties

When data-auto="false" is set, or to attach properties to a pageview, send it yourself:

js
reveata('pageview', { props: { section: 'docs' } });

Your #1 KPI

In Goals, select the star on the goal that matters most to make it your website's #1 KPI (editors and admins can, one goal per website). The dashboard still opens on visitors and revenue; the KPI is there when you want it:

  • The goal carries a #1 KPI badge in the dashboard's goals list and goal picker.
  • In the conversions card's Goal tab, select the goal and press Chart to see its completions over time. Press Back to overview for visitors and revenue again.
  • The button at the top of each source, page, location and device list switches between visitors, revenue and the goal's completions.

The ranking by the goal counts only that goal, while every row keeps all of its visitors. Filters and the date range apply as usual. Hiding the goal, or removing the star, takes the goal out of the sort button.

Funnels

Once goals arrive you can build funnels of 2 to 8 steps from pages and goals in the dashboard to see where people drop off between steps. To be told when a goal is completed, add an alert.

Was this helpful?