Skip to content

Goals

Define the conversions that matter, with or without code, and see which sources and pages actually produce them.

A goal counts a conversion whenever a visitor does something you care about. Once one exists, every breakdown gains conversions and conversion rate, so you can stop guessing which channel produces sign-ups rather than merely traffic.

New to goals? Track goals is the five-minute version. This page is the reference.

Goal kinds

KindPattern meansExample
PageviewA page to match, using the match type below./thank-you
Custom eventThe event name your code sends with statsy.goal().signup
ClickA CSS selector for the element clicked.#buy-button
Scroll depthA page to match, plus the depth as a percentage./pricing
Outbound linkThe destination host. Use * for any outbound link.github.com

Match types

Pageview and scroll goals also choose how the pattern is matched:

  • Path matches this path and everything under it. /checkout also matches /checkout/success.
  • Wildcard uses *. /blog/* matches every post; /docs/*/install matches every install page.
  • Exact matches that path only, ignoring the query string.

Default value

A goal can carry a default value, credited when the event itself carries none. It is useful for putting a rough number on a demo request or a trial start. Real money still comes from payments, and the two are reported separately, so a goal value never inflates your revenue.

Tracking from code

js
statsy.goal('signup', { plan: 'pro' });

// Queue calls made before the script has loaded:
window.statsyq = window.statsyq || [];
statsyq.push(['goal', 'signup', { plan: 'pro' }]);

Properties are optional and may be strings, numbers or booleans. The same goal can also be fired straight from markup, with no JavaScript of your own:

html
<button data-statsy-goal="signup" data-statsy-prop-plan="pro">Start free</button>

The attribute works on the element or anything inside it, and every data-statsy-prop-* attribute becomes a property.

Goals you get for free

NameFires onTurn off with
outboundA click on a link to any other host.data-track-outbound="false"
downloadA click on a link ending in pdf, zip, dmg, exe, csv, xlsx, docx, mp3 or mp4.data-track-downloads="false"
checkout_startA click on a hosted checkout link, recorded with the provider name.

Scroll depth is also recorded on every page without a goal existing, which is what scroll goals and heatmaps read. Turn it off with data-track-scroll="false".

Using a goal

  • Open it for a breakdown of the sources and pages that drive it.
  • Filter any report by goal, or make it the last step of a funnel.
  • Fire an alert when it completes.

Goals can also be created through the REST API and by an AI assistant over MCP, and a server-side conversion can be sent from the CLI with statsy goals send.

Last updated · Markdown version