Docs menuInstall CentPath › Install the script
Add CentPath to an HTML site
On this page
Add CentPath to a site you build from HTML files, so every page that carries the snippet counts its visits.
1. Copy your snippet
In CentPath, open your site, go to Setup → Install and click Copy. The snippet you copy holds your site's own id, so every visit counts for the right site:
<script>window.analytics = window.analytics || Object.assign([], { q: [], goal: function () { this.q.push(arguments); } });</script>
<script defer src="https://centpath.app/script/p.js" data-site-id="YOUR_SITE_ID"></script>2. Paste it into the head of your pages
- Open a page's HTML file in your editor.
- Paste the snippet inside
<head>, before</head>. Keep its two lines together, the first line above the second, so goals your page sends early wait for the script. - Do the same in every page you want counted. If your pages share a header file or template, paste it there once instead, so every page built from it carries the snippet.
3. Upload your files
Upload the changed files to your host, the way you publish any change, so your live pages carry the snippet.
Verify the setup
- Open your live site in a new tab and load a page.
- In CentPath, look under the steps in Setup → Install: Waiting for your first pageview… turns into First pageview received. once the visit arrives.
- If it said First pageview received. before you started, your site has had visits already: look for this one in your dashboard instead. Reload it, and the visit shows in the Visits feed, usually within a minute.
Check your installation shows more ways to check a page.
Troubleshooting
One page shows no visits
That page's file doesn't carry the snippet. Open its source in your browser, search for your site's id, and add the snippet to that file if it's missing.
Your live page still shows the old version
Your host or its CDN may serve a cached copy for a while. Clear its cache, or wait, then load the page again.
Visits from your computer count too
A page you open from localhost while you work on it counts like any other, since it loads the snippet too. To keep test visits out, see Troubleshooting.