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.
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
| Attribute | What it does |
|---|---|
data-site-id | Required. Your site id from Site settings, starts with rs_. |
data-domain | Required. Your root domain, e.g. yoursite.com. Subdomains are covered automatically; visitor cookies are set for the whole domain. |
data-cookieless | Store nothing in the browser. Visitors are identified by a hash that rotates daily. No consent banner needed. |
data-allow-localhost | Also track visits on localhost. Off by default so development traffic never pollutes your stats. |
data-api-url | Send events to a different endpoint, e.g. a first-party proxy on your own domain. |
data-disable-payments | Skip the automatic Stripe Checkout redirect capture described below. |
data-disable-console | Silence 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.