# Troubleshooting

> What to do when no visits arrive: a Content-Security-Policy, test visits, ad blockers, a wrong site id and single-page apps.

Find what you see below, then follow its steps. Most problems come down to a page that doesn't load the snippet, or a browser that stops it.

## No visits arrive

1. Load a page of your live site, not a preview your site builder keeps for itself: a preview often leaves your custom code out.
2. [Check the page's source](https://centpath.app/docs/verify-installation#check-the-pages-source) for your site's id. If it isn't there, publish your change, or add the snippet to the template that page uses.
3. [Check the request in DevTools](https://centpath.app/docs/verify-installation#check-the-request-in-devtools). Its status says whether CentPath received the visit.
4. Turn off your ad blocker for your site, or test in a private window with your extensions off.
5. Open the browser's **Console** tab and look for a message that starts with `[analytics]` or names a Content-Security-Policy. Each case is below.

If **Exclude visits from cloud servers** is on, in **Setup** → **Advanced** under **Bot filtering**, a visit over a VPN, a work network or a cloud desktop that runs on a cloud provider's servers is left out of your dashboard. It's still stored, so turning the switch off brings it back. Test from your usual connection.

## A Content-Security-Policy blocks the script

The console says the browser refused to load a script, run an inline script, or connect, because it breaks your site's Content-Security-Policy. Your policy decides which scripts run and where a page may send requests.

1. Add `https://centpath.app` to `script-src`, so the script can load.
2. Add `https://centpath.app` to `connect-src`, so the script can send its visits.
3. Let the snippet's first line run: give it your page's nonce, or add its hash to `script-src`. Chrome's message names the hash it expects.

Change the policy where your site sets it: a header in your server or host, or a meta tag in your pages.

## Visits from localhost or a staging site are counted

CentPath counts every page that loads your snippet, on any address: your live site, `localhost` and a staging copy alike. It has no filter by address today.

To keep test visits out, load the snippet only on your live site: for example, add it to your layout only when your site is built for production, or give your staging site no snippet at all.

## Some visits are missing

Some ad blockers and privacy extensions stop analytics scripts, and may stop CentPath's. Visits from those browsers aren't counted, and no setting brings them back.

To check that this is the cause, open your site in a private window with your extensions off, then load a page: if that visit arrives, the snippet works.

A browser driven by a script, as test tools drive one, says so to every page, and CentPath counts none of its visits either. Test in your own browser.

## Visits go to another site, or nowhere

The snippet carries the id of the site its visits count for. A snippet copied from another site's **Setup**, or an id changed by hand, sends visits to that other site, or to no site at all.

1. Open the right site in CentPath and go to **Setup** → **Install**.
2. Copy the snippet again with **Copy** and replace the one on your site.

If the console says `[analytics] bad data-site-id`, the id in your snippet isn't a whole site id, and the script sends nothing. Copy the snippet again, as above.

## A single-page app counts only some page changes

The script counts a page view when the page loads, and again each time your app changes the path of the address. It compares the path alone.

- A change to the query string, like `?tab=2`, isn't a new page view.
- A change after a `#`, like `/#/pricing`, isn't either: an app whose router keeps its pages after a `#` counts as one page.

To count each screen, give each one its own path, like `/pricing`. [The script](https://centpath.app/docs/script#single-page-apps) explains what it counts.

## You added the snippet twice

The script runs once a page, however many copies of the snippet the page holds, so a visit is never counted twice. Remove the extra copy all the same, so there's one place to change it.
