Skip to content
Tracking and technical

What is a tracking script?

3 min read · Updated · By the Reveata team

Short answerA tracking script is a small JavaScript file you add to every page of a website, which runs in each visitor's browser and sends page views, clicks and other actions to an analytics service.

The tracking script is where most web analytics begins. It is usually one line of HTML, a <script> tag pointing at a file hosted by the analytics provider. Once loaded, it watches what happens on the page and reports it.

What a tracking script does

  1. Loads from the provider's address, or from your own domain through a proxy.
  2. Reads the context: the page address, the referrer, screen size, language and time zone.
  3. Identifies the browser for counting, usually with a random id in a first-party cookie, or with nothing stored at all in cookieless setups.
  4. Sends events: a page view on load, and goals, outbound clicks or scroll depth as they happen.
  5. Exposes an API so your own code can record actions, such as a sign-up.

The Reveata script

You paste one snippet inside the <head> of every page:

html
<script defer data-website-id="ws_your_tracking_id" src="https://reveata.com/js/script.js"></script>

Your dashboard shows the snippet with your own tracking id. It loads with defer, so it never blocks your page, and it never throws errors into your site. Single-page apps are handled automatically: a page view is recorded on every history.pushState, replaceState and back or forward navigation (Install the script).

Without any setup it also records how far people scroll, how long each page stays visible and clicks on links to other sites. Options are set with data- attributes, for example data-cookieless="true" to store nothing in the browser, or data-exclude-paths="/admin/*" to skip private pages.

For each event it sends the page URL, the referrer, the screen and window size, the browser language and the time zone, plus any goal name and properties you add. The server works out the rest and never stores IP addresses (Privacy, cookies and cookieless mode).

Broken links, file downloads, form submissions and Core Web Vitals are opt-in, in a second script, script.extras.js, so the main one stays small.

The script adds window.reveata, with commands such as reveata('goal', 'signup') and reveata('identify', …). The full list is in the JavaScript API.

Things that stop a script working

  • The snippet is missing from some pages, often templates that were not updated.
  • A Content Security Policy does not list the script's address; see Content Security Policy.
  • An ad blocker cancels the request; see ad blocker.
  • A consent tool holds it back until people accept.
  • Development hosts. Reveata ignores localhost by default so test visits stay out of your numbers.

Adding data-debug="true" makes the Reveata script log what it does, and why it is off, in the browser console.

Performance

A script that loads with defer or async does not hold up the first paint of the page. Size still matters on slow phones, which is why optional features belong in separate files. Avoid loading two analytics scripts that do the same job.

Frequently asked questions

Where should the tracking script go?

In the <head> of every page, so it starts loading early. With defer it runs after the page is parsed, so it does not slow down the content people see first.

Can I install the script without editing code?

Yes. Site builders usually have a field for code in the head, and a tag manager can load it too. Reveata has guides for frameworks and site builders.

How do I know it is working?

Open your site and watch the realtime view in your analytics tool. In Reveata, your visit should appear within a few seconds; Verify your installation walks through it.

See it with your own numbersReveata ties every visit and sale to the source that brought it. Add your website in a minute.
Get started
Was this page useful?
GlossaryWhat is a tracking pixel?A tracking pixel is a tiny, usually invisible image (often 1×1 pixel) embedded in a web page or email, whose download tells a server that the page or message was opened, along with details such as the time, the browser and the IP address.GlossaryWhat is a tag manager?A tag manager is a tool, such as Google Tag Manager, that you install once on your website and then use to add, change and fire analytics and marketing scripts (tags) from a web dashboard instead of editing your site's code each time.GlossaryWhat is a Content Security Policy (CSP)?A Content Security Policy (CSP) is a set of rules a website sends to the browser, usually in a Content-Security-Policy header, listing which sources of scripts, styles, images and network connections the page is allowed to use, so injected or unexpected code is blocked.GlossaryWhat are Core Web Vitals?Core Web Vitals are three measurements Google uses to describe a page's real-world user experience, namely Largest Contentful Paint (loading), Interaction to Next Paint (responsiveness) and Cumulative Layout Shift (visual stability).GlossaryWhat are event properties?Event properties are key–value details attached to an analytics event, such as the plan chosen or the button clicked on a signup event, so you can break one event down by those details instead of creating a separate event for every variation.GlossaryWhat is a canonical URL?A canonical URL is the one preferred address you want search engines to index and show for a page whose content is reachable at several URLs, usually declared with a rel="canonical" link in the page's head.