Docs menuInstall CentPath › Install the script
Add CentPath to WordPress
On this page
Add CentPath to your WordPress site with the free WPCode plugin, so every page of your site counts its visits.
Before you start
You need a WordPress administrator account, to install a plugin. CentPath has no WordPress plugin of its own: WPCode puts the snippet in your pages' <head>.
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. Install WPCode
- In your WordPress dashboard, go to Plugins → Add New Plugin.
- Search for
WPCode. Its full name is WPCode – Insert Headers and Footers + Custom Code Snippets. - Click Install Now, then Activate. A Code Snippets menu appears in your dashboard.
3. Paste the snippet into the header
- Go to Code Snippets → Header & Footer.
- Paste the snippet into the Header box. WPCode adds what it holds to the
<head>of every page, so you paste it once. - Click Save Changes.
4. Clear your cache
If your site uses a caching plugin, or your host caches pages, clear that cache. Until you do, visitors may get pages saved before the snippet was there.
Verify the setup
- Open your live site in a private window 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
You can't add plugins
Some hosts and plans don't let you install plugins. Ask your host how to add code to your site's <head>, and paste the snippet there.
You'd rather not add a plugin
Edit your theme instead, in a child theme, so a theme update doesn't remove the snippet:
- In your child theme's
header.php, paste the snippet before</head>. - Save the file and upload it, or save it in your theme editor.
A block theme has no header.php. With one, use WPCode as above.
Your theme already has a box for header code
Some themes have their own setting for code in the <head>. Pasting the snippet there works too. Keep it in one place only, WPCode or the theme, so you know where to change it.
Pages still don't carry the snippet
Clear your caching plugin's cache and your host's, then load the page again. If a page is served by a page builder with its own template, open that page's source and search for your site's id to check.