Tracking script
Install the required stub on every page, ideally in the head tag of your root layout/template. It defers the load of the tracker script (7kb) so it doesn't impact your page load time.
<script>(function(w,n,u,c){
if(u&&typeof u==="object"){c=u;u=null}c=c||{};u=u||"https://in.revscope.co/";c.url=u;u+=n+".js";c.project=n;n=typeof c.name==="string"&&c.name||"dispatch";if(typeof w[n]==="function")return;var q=[];function f(){q.push([].slice.call(arguments));}f.q=f.a=q;f.c=c;w[n]=f;var s=document.createElement("script");s.src=u;s.defer=true;document.head.appendChild(s);
})(window, "REPLACE_WITH_PROJECT_NAME");
</script>
Call dispatch("event", "signup") (and the other commands in
these docs) after the stub is installed. If dispatch is already
used on the page, set name in the config object below and call
that function instead.
Project name and server URL
The stub's project name (second argument) and optional server URL select where the tracking data goes:
| Setting | Description |
|---|---|
| Project name |
The project the data lands in. Replace
REPLACE_WITH_PROJECT_NAME with the project name from
your dashboard.
|
| Server URL |
Optional third argument: the base URL that serves the tracker and
receives events. It must end in a slash, is always https://, and defaults to https://in.revscope.co/ when omitted. Change it only when
routing RevScope through your own domain with a
CNAME or reverse proxy to avoid ad blockers.
|
What's tracked automatically
- Pageviews, including SPA navigations (History API and hash changes)
- Sessions with landing page, referrer, and campaign attribution
- Engagement time and scroll depth per page
- Outbound link clicks (as
revscope-outbound-clickevents) -
UTM parameters (
utm_source,utm_medium,utm_campaign,utm_content,utm_term) and ad click IDs (gclid, fbclid, msclkid, ttclid, and more) - Referrer classification: search engines, AI assistants, social, email, affiliates
- Country and city (from IP, never stored), device, browser, OS, viewport
Bots are filtered automatically and tracking requests are batched (up to 20 per request) to minimize network overhead.
Configuration options
Pass an optional config object as the stub's fourth argument. It is stored
on the dispatch function as .c. You can also use the
equivalent data-* name if you set attributes on the loaded
script element (except name, which is stub-only):
| Config / attribute | Description |
|---|---|
hostname / data-hostname | Report traffic under a custom hostname. Useful for unifying staging domains or white-label deployments. |
mode / data-mode |
Set to "hash" for single-page apps that route on the
fragment (/app#/pricing): the fragment becomes part of
the tracked path and hash changes count as pageviews.
|
ignorePages / data-ignore-pages |
Comma-separated list of paths to exclude from tracking, e.g. /admin,/preview.
|
includeParams / data-include-params | Comma-separated list of extra query parameters to keep on tracked URLs. By default only campaign and click-ID parameters are kept, so personal data in URLs never reaches RevScope. |
name |
Window function for the JavaScript API. Defaults to
dispatch. Set this only when that name is already used
on the page; there is no data-* equivalent because the
stub has to choose the name before the tracker script loads.
|
Subdomains and cross-domain tracking
Create your project under your root domain (e.g. example.com)
and install the same snippet on any subdomains
(app.example.com, blog.example.com). Sessions are
unified across your whole domain, so a visitor who lands on your blog and
buys in your app is attributed correctly.
Consent and privacy
RevScope is privacy-friendly by default: no cross-site tracking, no fingerprinting, no personal data collection. In regions that require consent for cookies (EU, UK), the script automatically falls back to cookieless, server-side attribution until consent is granted. To optionally signal consent from your own banner:
// allow analytics cookies
dispatch("set_consent", "granted");
// use cookieless measurement
dispatch("set_consent", "denied");
// stop all measurement
dispatch("set_consent", "disabled"); See GDPR for the EU legal overview and privacy-mode behavior, Privacy laws for other regions, and Consent for connecting your consent manager. To reduce traffic lost to filter lists, see Ad blockers.