Documentation

Everything you need to install RevSonar, track what matters, and see the revenue behind your traffic.

1. Install the script

Create a site in the dashboard, then paste your snippet into the <head>of every page. Your exact snippet, with the site id filled in, is on the site's settings page.

<script defer
  data-site-id="rs_xxxxxxxxxx"
  data-domain="yoursite.com"
  src="https://revsonar.com/js/script.js"></script>

The script is about 2 KB, loads with defer, and never slows your page down. Single-page apps work out of the box: route changes via the History API are tracked as pageviews automatically.

Verify it works: open your site and your RevSonar dashboard. The first pageview shows up within a minute. Traffic on localhost is ignored by default, so test on a deployed site or add data-allow-localhost.

2. Track goals

Goals are the actions you care about: signups, trial starts, button clicks. The easiest way is an attribute, no JavaScript required. Extra data-rs-goal-* attributes become properties on the event.

<button data-rs-goal="signup" data-rs-goal-plan="growth">
  Create account
</button>

For anything dynamic, call the JavaScript API. If you call it before the script has loaded, add this tiny stub once and calls are queued and replayed:

<script>
  window.revsonar = window.revsonar || function () {
    (window.revsonar.q = window.revsonar.q || []).push(arguments);
  };
</script>
// Track a goal, with optional string properties
window.revsonar("signup", { plan: "growth" });

// Link the current visitor to a user in your app
window.revsonar("identify", { user_id: "42", name: "Ada Lovelace" });

Goal names are lowercased and may contain letters, numbers, _, : and - (max 64 characters). New goals register themselves the first time they are seen. Clicks on links to other domains are tracked automatically as the outbound_click goal.

3. Connect Stripe for revenue attribution

This is the part that makes RevSonar different: every payment is traced back to the channel, campaign, and landing page that earned it. Open your site's settings and pick one of two routes:

  • Stripe Connect (recommended). Click Connect Stripe and approve read-only access. Payments flow in with full attribution, nothing to configure in Stripe.
  • Webhook. Add the per-site webhook endpoint shown in settings to your Stripe dashboard and paste the signing secret back into RevSonar.

Using Stripe Payment Links or a hosted Checkout page? Append ?session_id={CHECKOUT_SESSION_ID}to your success URL. The script picks it up on the thank-you page and ties the payment to the visitor's session.

Cookieless mode

By default RevSonar sets two first-party cookies: revsonar_visitor_id (2 years) and revsonar_session_id (30 minutes). Add data-cookieless to the snippet, or flip the switch in site settings, and nothing is stored in the browser at all. Visitors are then counted with a privacy-preserving hash that rotates every day, so no one can be followed across days or across sites.

Filtering out noise

Bots are dropped automatically. In site settings you can also exclude your own traffic by IP address, country, hostname, or path (wildcards like /drafts/* work). Excluded events are not stored and not billed.

Script attribute reference

AttributeWhat it does
data-site-idRequired. Your site id from Site settings, starts with rs_.
data-domainRequired. Your root domain, e.g. yoursite.com. Subdomains are covered automatically; visitor cookies are set for the whole domain.
data-cookielessStore nothing in the browser. Visitors are identified by a hash that rotates daily. No consent banner needed.
data-allow-localhostAlso track visits on localhost. Off by default so development traffic never pollutes your stats.
data-api-urlSend events to a different endpoint, e.g. a first-party proxy on your own domain.
data-disable-paymentsSkip the automatic Stripe Checkout redirect capture described below.
data-disable-consoleSilence the script's console warnings.

What counts as an event

Plans are billed by events. An event is a pageview, a goal, or a payment. If you go over your plan's limit we keep collecting your data; nothing is ever dropped or lost. See pricing for the current limits.

Need a hand?

Email support@revsonar.com and a human will get back to you.