Overview
Web Analytics tells you which pages people are looking at, where they came from, and roughly where in the world they are. That's about it, and that's on purpose.
There are no cookies, no visitor ids, and no tracking people across sites. It doesn't store IP addresses, and it never knows who anyone is. Which means, in most cases, no cookie banner. (We're not lawyers, so do check what applies to you. But that's the idea.)
What you get instead is a nice, honest count of page views:
- Which pages are popular, and how that changes over time.
- Where people came from: search engines, social media, newsletters, other sites.
- How your tagged campaign links are doing.
- Devices, browsers, operating systems, languages, and a map of towns and cities.
Setting it up
1. Create an application
An application is one site you want to measure. Head to Web Analytics and click to create one.
- Application name: whatever helps you tell it apart, like Marketing site.
- Domain: where the site lives, like
example.com. You can paste a full URL and it'll be trimmed down to the domain.
The domain matters. Beacons are only counted when they come from that domain or one of its subdomains, so example.com covers www.example.com and blog.example.com too. More on why below.
2. Create a token
Open the application, go to Tokens, and click Create Token. Give it a name so you can tell it apart from any others later, like Production.
Tokens aren't secret. They sit in your page's source for anyone to see, and that's fine (again, more on that below). But if you ever want to stop a token working, delete it. Beacons sent with it are rejected from then on.
3. Add the snippet
Paste this into the pages you want to measure, swapping YOUR_TOKEN for your token. Just before </head> is a good spot.
<script async src="https://dev-team-tools.com/wa.js" data-token="YOUR_TOKEN"></script>
You can also copy it from the application's Tokens page.
Deploy your site, visit a page, and you should see the hit on your dashboard within a few seconds. Nice!
Using React, Svelte, Vue or similar? Page changes are counted too, with no extra code. See Single page apps for how.
Keep the async
It lets your page carry on loading while the script downloads, so even if we're having a bad day, your site isn't. Without it, a slow response from us would hold up your page.
Rather not load a script?
Some sites can't load scripts from other domains, or would rather not. This does the same job inline, but only counts the first page of a visit, so it's best for sites where every click loads a new page. Use it instead of the script tag, not as well, or every page gets counted twice.
<script> (function () { var query = new URLSearchParams(location.search); fetch("https://api.dev-team-tools.com/analytics/beacons", { method: "PUT", headers: { Authorization: "Bearer YOUR_TOKEN", "Content-Type": "application/json", }, body: JSON.stringify({ path: location.pathname, referrer: document.referrer, utmSource: query.get("utm_source") || query.get("ref"), utmMedium: query.get("utm_medium"), utmCampaign: query.get("utm_campaign"), }), keepalive: true, }); })();</script>
What gets sent, and what doesn't
The snippet sends:
| Field | What it is |
|---|---|
path |
The page being viewed, like /blog/my-post. No query string |
referrer |
The page the visitor came from, if their browser says |
utmSource |
utm_source from the link they followed, or ref if there's no utm_source |
utmMedium |
utm_medium from the link they followed |
utmCampaign |
utm_campaign from the link they followed |
Everything else is worked out from the request itself, and only the result is kept:
- Town and country, from the request's location. Never anything more precise than a town.
- Device: phone, tablet, desktop, and so on.
- Browser and operating system families. Versions aren't recorded.
- Language, like
en, without the region. - Whether it's a bot, judged from the user agent.
Only the site the visitor came from is kept (like news.ycombinator.com), not the full address of the page. Links between pages on your own site aren't counted as a source at all.
Why the domain check?
Your token is in your page's source, so anyone could copy it and send beacons. To stop that skewing your numbers, beacons are only counted when the browser says they came from your application's domain.
A couple of knock-on effects:
- Testing locally won't show up. Beacons from
localhostare rejected. Honestly, that's a good thing, as you don't want your own testing mixed in with real traffic. If you'd like to see it working before you go live, make a second application for a staging site (likestage.example.com) and use its token there. - Beacons have to come from a browser. A request from your server won't say which site it came from, so it's rejected.
- Changed domain? Update it with the application's Edit button. It can take up to a minute before beacons from the new domain are accepted.
Where next?
- Single page apps, if your site navigates without reloading.
- Campaign links, to see how the links you share are doing.
- Reading your data, for what's on the dashboard and how it's counted.