Skip to content
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

  1. In CentPath, open your site and go to Setup → Goals.
  2. 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.
  3. 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.

  1. Copy the attribute, from Setup or from here, with your goal's name in place of signup:
data-goal="signup"
  1. Put it on the element itself: an <a> link, a <button>, or a <form>. On any other element it sends nothing.
  2. 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:

OnThe goal is sent
A link or a buttoneach time it is clicked, on whatever part of it
A formeach 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

  1. On your live site, click the link or button, or send the form.
  2. Open your dashboard: the goal is in the Goals card, under its name, usually within a minute.

Troubleshooting

The goal never shows

  1. Check that the attribute is on the <a>, <button> or <form> itself, not on a <div> or an <input> around or inside it.
  2. Check that the page loads the snippet: Check your installation shows how.
  3. Check the goal's name: it is counted letter for letter, so Signup and signup are 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.