# Add CentPath to WordPress

> Add the snippet to every page of your WordPress site with the free WPCode plugin's Header & Footer box, or with a child theme.

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:

```html
<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

1. In your WordPress dashboard, go to **Plugins** → **Add New Plugin**.
2. Search for `WPCode`. Its full name is WPCode – Insert Headers and Footers + Custom Code Snippets.
3. Click **Install Now**, then **Activate**. A **Code Snippets** menu appears in your dashboard.

## 3. Paste the snippet into the header

1. Go to **Code Snippets** → **Header & Footer**.
2. Paste the snippet into the **Header** box. WPCode adds what it holds to the `<head>` of every page, so you paste it once.
3. 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

1. Open your live site in a private window and load a page.
2. In CentPath, look under the steps in **Setup** → **Install**: **Waiting for your first pageview…** turns into **First pageview received.** once the visit arrives.
3. 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](https://centpath.app/docs/verify-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:

1. In your child theme's `header.php`, paste the snippet before `</head>`.
2. 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.
