> ## Documentation Index
> Fetch the complete documentation index at: https://docs.traceten.com/llms.txt
> Use this file to discover all available pages before exploring further.

# WordPress

> Add Traceten to WordPress using the theme editor or a header injection plugin.

## What this lets you do

Track AI-referred traffic on every page of your WordPress site without modifying plugin code or a child theme.

## Before you start

* Your Traceten site key, from **Sites → Install** in the [dashboard](https://app.traceten.com/dashboard).
* WordPress admin access.
* If you plan to use the theme editor: write access to your active theme's files.

## Method 1: Insert Headers and Footers plugin (recommended)

This method works regardless of your theme and survives theme updates.

<Steps>
  <Step title="Install the plugin">
    In your WordPress admin, go to **Plugins → Add New** and search for **Insert Headers and Footers** (by WPBeginner). Install and activate it.
  </Step>

  <Step title="Open the plugin settings">Go to **Settings → Insert Headers and Footers**.</Step>

  <Step title="Paste the snippet into the Header section">
    In the **Scripts in Header** box, paste your snippet tag:

    ```html theme={null}
    <script
      async
      src="https://cdn.traceten.com/tt.min.js"
      data-site="ttid_7Rb4TrC1dTbnD8w3s1TS12"
      data-cookie-domain="example.com"
    ></script>
    ```

    Copy the whole tag from **Sites → Install** for your site so `data-site` (your site key) is already yours. `data-cookie-domain` is your own domain, which keeps one visitor as one visitor across your subdomains. It's off by default, so it only appears on the tag once you've confirmed a value under **Sites → Settings → Cookies**.
  </Step>

  <Step title="Save">
    Click **Save**. The snippet is now live on every page of your site.
  </Step>
</Steps>

## Method 2: Theme editor

Use this only if you are comfortable editing theme files directly. Child themes are recommended so your changes survive theme updates.

<Steps>
  <Step title="Open the theme editor">
    Go to **Appearance → Theme Editor**.

    If you see a warning that direct theme editing is disabled, you'll need to use Method 1 or edit the file via FTP/SFTP.
  </Step>

  <Step title="Open header.php">
    In the file list on the right, click **header.php** (under Theme Files).
  </Step>

  <Step title="Find the closing </head> tag">
    Use Ctrl+F (or Cmd+F on Mac) to find `</head>`. Look for the line that reads `</head>` or contains `wp_head()` followed by `</head>`.
  </Step>

  <Step title="Paste the snippet just before </head>">
    ```php theme={null}
    <?php wp_head(); ?>
    <!-- Traceten AI traffic attribution -->
    <script
      async
      src="https://cdn.traceten.com/tt.min.js"
      data-site="ttid_7Rb4TrC1dTbnD8w3s1TS12"
      data-cookie-domain="example.com"
    ></script>
    </head>
    ```

    Copy the whole tag from **Sites → Install** for your site so `data-site` (your site key) is already yours. `data-cookie-domain` is your own domain, which keeps one visitor as one visitor across your subdomains. It's off by default, so it only appears on the tag once you've confirmed a value under **Sites → Settings → Cookies**.
  </Step>

  <Step title="Click Update File">
    Scroll to the bottom and click **Update File**. The snippet is now live on all pages.
  </Step>
</Steps>

## Verify installation

Open your site in a browser, then open **Sites → Install** in the [dashboard](https://app.traceten.com/dashboard) and look at the **Verify** step. It should turn green within 30 seconds of a pageview.

## Notes

**Caching plugins.** If you use WP Rocket, W3 Total Cache, or another caching plugin, clear the cache after installing the snippet. Otherwise cached pages won't include it.

**Page builders.** Elementor, Divi, and Beaver Builder each have their own "custom code" sections. Using the Insert Headers and Footers plugin is simpler than hunting through builder settings.

**Child themes.** If you edit `header.php` directly in a parent theme, a theme update will overwrite your change. Always use a [child theme](https://developer.wordpress.org/themes/advanced-topics/child-themes/) or use Method 1.

## Next steps

* [Verify the snippet is firing](/install/verify)
* [Troubleshooting](/install/troubleshooting)
