peregrine
DocsDemoGet started

Docs

Goals and custom events

A goal is anything your site reports besides a pageview: a signup, a click on “Start trial”, a finished onboarding step. The Goals panel shows each one as the share of visitors who did it. Click a channel and it shows the same numbers for just the people that channel brought.

Without code: data-goal

Add data-goal to any element, and every click on it is counted:

<a href="/sign-up" data-goal="signup_click">Start free trial</a>

To tell several buttons for the same goal apart, add data-goal-* attributes. Each one is saved with the event, along with the page it was clicked on:

<a href="/sign-up" data-goal="signup_click" data-goal-where="hero">Start free trial</a>
<a href="/sign-up" data-goal="signup_click" data-goal-where="pricing">Start free trial</a>

This is the way to count clicks on links that stay on your own site, such as a signup button. Links that leave your site are already counted, see below.

From JavaScript: window.peregrine()

For things that are not a click, such as a form that submitted successfully, call the tracker yourself:

window.peregrine('signup');

// with details
window.peregrine('signup', { plan: 'pro' });

The tracker loads with defer, so window.peregrine exists once the page has been parsed. In code that can run earlier, check before calling:

window.peregrine && window.peregrine('signup');

Naming rules

  • Names use lowercase letters, digits and underscores, up to 32 characters. Uppercase is lowercased. Anything else is dropped without an error, so sign-up or Sign Up will never appear.
  • pageview, outbound and purchase are taken. Pick other names for your own goals.
  • Details are kept if they come to 1,000 characters or less as JSON. Over that, the event is still counted and the details are dropped. Each data-goal-* value is cut at 100 characters.

Already counted for you

  • Pageviews, including route changes in single-page apps.
  • Outbound links. Every click on a link to another site, with the page it was on and where it led. These have their own panel. App Store links, affiliate links and links to your docs elsewhere are covered with no setup.
  • Purchases, read from your payment provider rather than the browser. See revenue attribution.

More docs

  • Install the tracker
  • Revenue attribution
  • Sale notifications on Telegram
  • How channels are decided
  • Bots and filtering
  • What is collected
  • Peregrine for Polar
  • Peregrine for Lemon Squeezy
  • Peregrine for Dodo Payments

Something missing? Write to us from the footer. Or see a real dashboard in the demo, or start a free trial.

peregrine
DemoDocsIntegrationsCompareUTM builderSign in
© 2026
TermsPrivacyDPA

Contact us

Something is broken or wrong

hello@justperegrine.com
Featured onFeatured on DanielLaunchesLaunched on LaunchPanda