Docs menuTrack goals › Set up goals
Count clicks and form sends
On this page
Count a click on a link or button, or a form sent, by adding one attribute to it, with no script of your own.
Before you start
The page must load the CentPath snippet, as Install CentPath shows: the script it loads reads the attribute.
1. Name the goal in Setup
- In CentPath, open your site and go to Setup → Goals.
- Click Add a goal, pick Your site sends an event and type the goal's name in Name, like
signup. Setup shows the attribute with that name in it. - Click Add goal. The goal is listed as not sent yet until its first one arrives, and counts from then.
You can skip this step: a goal your site sends joins the list on its own when it first arrives.
2. Add the attribute to the link, button or form
- Copy the attribute, from Setup or from here, with your goal's name in place of
signup:
data-goal="signup"- Put it on the element itself: an
<a>link, a<button>, or a<form>. On any other element it sends nothing. - In a site builder, look for the element's custom attributes: give it one named
data-goal, with the goal's name as its value.
What sends the goal:
| On | The goal is sent |
|---|---|
| A link or a button | each time it is clicked, on whatever part of it |
| A form | each time it is sent, once the browser's own checks of its fields pass |
The goal reaches CentPath even when the click opens another page: the browser sends it on its way out.
3. Publish your site
Save and publish, so the live pages carry the attribute.
Verify the setup
- On your live site, click the link or button, or send the form.
- Open your dashboard: the goal is in the Goals card, under its name, usually within a minute.
Troubleshooting
The goal never shows
- Check that the attribute is on the
<a>,<button>or<form>itself, not on a<div>or an<input>around or inside it. - Check that the page loads the snippet: Check your installation shows how.
- Check the goal's name: it is counted letter for letter, so
Signupandsignupare two goals.
A form's goal never shows
The goal is sent when the browser sends the form. A form your own code sends without that, with form.submit() for one, sends nothing: call the goal from that code instead, as Send goals from JavaScript shows.
A goal counts twice for one sign-up
A button inside a form, both with the attribute, sends two goals: the button's on the click, the form's when it is sent. Keep the attribute on one of them.