Skip to content

Quick start

From an accepted invitation to your first recorded page view, in about five minutes.

3 min read Updated Suggest an edit

Before you begin

  • An accepted invitation and a workspace.
  • The domain your site is served from, for example example.com.
  • A way to edit the <head> of every page — a layout file, a theme setting or a tag manager.

Create a project

Open your workspace's Projects and choose New project. A project is one site or one product: give it the name your team will recognise and the time zone its reports should use.

One project per site

Keep staging out of it. A second project for staging is easier to read than one project with both kinds of traffic mixed in.

Find the install key

  1. Open the project and select Keys.
  2. The install tag is at the top of the page, with the project's install key already in it.
  3. Select Copy tag.

An owner or an administrator of the workspace sees the full tag. When the project has no install key yet, they create it with Create the install key.

An install key is public: it sits in your page source where anyone can read it. It can only send events to its own project and can read nothing back. Allowed origins is what stops a copied key being useful anywhere else.

Install the tracker

Add the tracker before the closing </head> tag on each page, with the project's install key in place of the placeholder.

HTML
<script defer src="https://api.datavisitors.com/assets/sg.js" data-key="YOUR-INSTALL-KEY"></script>

The key is the project's; the address is the analytics service's. The script posts events to https://api.datavisitors.com/api/event.

Name the hosts the script may run on while you are here:

HTML
<script defer src="https://api.datavisitors.com/assets/sg.js" data-key="YOUR-INSTALL-KEY" data-domains="example.com,www.example.com"></script>

The tracker stays inactive when the current hostname is not in data-domains.

See the first visit

  1. Open a page that loads the tracker.
  2. Return to the project's Dashboard and reload it.

Data normally appears within seconds of a successful request. The Dashboard then shows page views, visitors, sessions, events, traffic sources and the rest of the aggregate cards.

First event received · pageview · / Sample

Nothing arriving?

  • Confirm the page source contains the script, and that the key in it is this project's.
  • Confirm data-domains, if you set it, contains the hostname in the address bar exactly.
  • The tracker deliberately sends nothing from localhost, from a file: URL, or when a robot is driving the page. Add data-include-localhost to the tag while you test locally. On localhost it prints one console warning that names the attribute.
  • An ad blocker or a strict privacy mode can stop the script from loading at all. Check your own visit in a clean browser profile.

The ingest endpoint answers 202 with accepted and rejected counts, and every rejection carries a stable code — Error codes lists them.