Docs menuInstall CentPath › Install the script
Add CentPath with Google Tag Manager
On this page
Add CentPath to your site through Google Tag Manager, so every page that loads your container counts its visits.
Before you start
Your site already loads your Tag Manager container on every page, and you can publish it. Tag Manager takes its own version of the snippet, made for a Custom HTML tag.
1. Copy your tag
In CentPath, open your site, go to Setup → Install, pick Google Tag Manager and click Copy. The tag 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); } });
(function () {
var script = document.createElement("script");
script.src = "https://centpath.app/script/p.js";
script.setAttribute("data-site-id", "YOUR_SITE_ID");
document.head.appendChild(script);
})();
</script>2. Create a Custom HTML tag
- In Tag Manager, open your container's workspace, go to Tags and click New.
- Click Tag Configuration and pick Custom HTML.
- Paste the tag above, with your site's id, into the HTML box.
- Name the tag
CentPath, so you can find it later.
3. Fire it on every page
- Click Triggering and pick Initialization - All Pages. It fires on every page, before most other tags, so the visit counts early.
- Click Save.
4. Publish your container
Click Submit, then Publish. Your tag reaches your live site only when you publish the container.
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.
Your page's source doesn't show CentPath's script, since Tag Manager adds it after the page loads, and any check that reads your page's HTML can't see it either. The first pageview is the proof, or the request in your browser's developer tools: see Check your installation.
Troubleshooting
No visit arrives after you published
- Check that the tag fires: use Tag Manager's Preview on your site, and look for the CentPath tag among the tags fired.
- Check that its id is your site's own, as in step 1, letter for letter.
- If your site has a Content-Security-Policy, see Troubleshooting.
A goal from your page's own code throws an error
The goal queue exists once Tag Manager has run the tag. A goal your page sends earlier, in a script of its own, finds nothing there. Mark the link, button or form with a data-goal attribute instead, as Set up goals shows: the script reads it when the visitor clicks or sends the form.