# WordPress

## Add Humblytics Analytics to WordPress

### 1 · Sign up (or log in)

Visit humblytics.com → Start Free Trial. Finish signup—or log in to your existing workspace.

### 2 · Add your website in Humblytics

In the sidebar, click **Add Website**.

* **Domain** – enter `your-domain.com` (omit `https://` and `www`)
* **Site Name** – internal label (e.g. `Marketing-Prod`)

Copy the snippet from **Install Tracking Code**:

html

```html
<!-- Start Humblytics Tracking Code -->
<script async src="https://app.humblytics.com/hmbl.min.js?id=YOUR_ID_HERE"></script>
<!-- End Humblytics Tracking Code -->
```

Keep this tab open—we'll return and click **Verify Website** once the tag is live.

### 3 · Add the script to WordPress

#### Option 1: Using a plugin (recommended)

**Best for:** Most WordPress sites—survives theme changes and updates

**Method A: WPCode (formerly Insert Headers and Footers)**

1. In your WordPress dashboard, go to **Plugins → Add New**
2. Search for **WPCode - Insert Headers and Footers**
3. Click **Install Now**, then **Activate**
4. Go to **Code Snippets → Header & Footer**
5. Paste your Humblytics script into the **Header** section
6. Click **Save Changes**

**Method B: Code Snippets (alternative)**

1. In your WordPress dashboard, go to **Plugins → Add New**
2. Search for **Code Snippets**
3. Click **Install Now**, then **Activate**
4. Go to **Snippets → Add New**
5. Give it a name (e.g., "Humblytics Analytics")
6. Paste this code:

php

```php
add_action('wp_head', function() {
    echo '<script async src="https://app.humblytics.com/hmbl.min.js?id=YOUR_ID_HERE"></script>';
});
```

7. Set to run **Only run on site front-end**
8. Click **Save Changes and Activate**

**Note**: Replace `YOUR_ID_HERE` with your actual project ID from Humblytics.

#### Option 2: Add to your theme

**Only use this if:** You manage a custom theme or child theme

⚠️ **Warning**: Direct theme edits will be lost when you update your theme. Always use a child theme or the plugin method instead.

**Using a child theme (safe method):**

1. Create or activate a child theme
2. In your child theme's `functions.php`, add:

php

```php
add_action('wp_head', function() {
    echo '<script async src="https://app.humblytics.com/hmbl.min.js?id=YOUR_ID_HERE"></script>';
});
```

3. Save the file

**Direct theme edit (not recommended):**

1. Go to **Appearance → Theme File Editor**
2. **Accept the warning** about editing theme files
3. Select **header.php** from the right sidebar
4. Locate the closing `</head>` tag
5. Paste your Humblytics script just before `</head>`
6. Click **Update File**

⚠️ **Important**: You'll need to re-add this script every time you update your theme.

### 4 · Verify installation

1. **Clear your cache** (if using WP Rocket, W3 Total Cache, etc.)
2. Return to Humblytics and click **Verify Website**
3. Open your live site in a private/incognito window and refresh once
4. Within \~30 seconds you should see a green **Verified** badge and live visitor count

**If verification fails, check:**

* Script ID matches your project in Humblytics
* You cleared WordPress cache and any CDN cache (Cloudflare, etc.)
* The script appears in your page source (right-click → View Page Source, search for "humblytics")
* No security plugins are blocking external scripts (check Wordfence, Sucuri settings)
* No ad-blockers or browser extensions are interfering

**Common WordPress caching plugins:**

* WP Rocket: Clear cache in **Settings → WP Rocket → Clear Cache**
* W3 Total Cache: Go to **Performance → Dashboard → Empty All Caches**
* WP Super Cache: Go to **Settings → WP Super Cache → Delete Cache**

### 5 · Explore & optimize

* **Dashboard** – track traffic, top pages, and referrers
* **Heatmaps** – auto-generated click & scroll analysis
* **Experiments** – run A/B tests without extra code (Experiments → New Test)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.humblytics.com/how-to-get-started/wordpress.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
