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

# WordPress pixel installation

> Install the Cometly pixel on WordPress and adjust caching plugins such as WP Rocket, so the pixel loads and each visit is tied to its source.

The Cometly pixel is a small script that tracks where your website visitors come from and captures opt-in data from your forms (name, email and phone number). This page shows you how to install the Cometly pixel on WordPress and keep caching or performance plugins from stopping it.

Once the pixel loads on your site, Cometly can tie each lead and sale back to the ad or channel that brought the visitor in. WordPress plugins that delay or combine JavaScript are a common reason the pixel misses visits, so the plugin check below matters as much as the install.

## Before you start

* The pixel goes in the `<head>` section of your site, so you need to be able to edit your theme's header file or use a header script manager plugin.

> [!WARNING]
>
> **Important for WooCommerce stores**
>
> If you are setting up the Cometly pixel for a WooCommerce store, do not install it manually. Follow the [WooCommerce integration guide](https://docs.cometly.com/integrations/platforms/woocommerce.md) instead. The Cometly WooCommerce plugin installs the pixel automatically, so no additional steps are needed.

## Install the Cometly pixel on WordPress

### Add the pixel script

1. In Cometly, click [**Setup**](https://app.cometly.com/space-setup?step=install-pixel) in the left sidebar and open step 2, **Install the Cometly pixel**. Under **Install the pixel**, click **Copy Code**.
2. Paste the pixel in the `<head>` section of your WordPress site. You can typically do this with a header script manager plugin or by editing your theme's header file.

### Make sure the pixel works

After adding the pixel:

* **Clear your cache** so the change takes effect.
* **Adjust JavaScript settings in plugins.** If a plugin defers or lazy-loads JavaScript, turn those options off so they do not interfere with the Cometly pixel.
* **Test the pixel installation.** Follow [Install and verify the Cometly pixel](https://docs.cometly.com/getting-started/install-pixel.md) for step-by-step instructions to confirm the pixel is loading properly.

> [!NOTE]
>
> If you pinned your site to a script version (Setup step 2 > **Pixel options** > **Script version** > **Pinned to a version**), paste the tag exactly as Cometly shows it and exclude it from optimization. If an optimizer plugin rewrites the tag, browsers refuse to run it.

## Check site performance and caching plugins

WordPress has a wide range of plugins for managing headers, performance and caching. Plugins such as WP Rocket, Autoptimize or similar tools may need adjusting for the Cometly pixel to work correctly.

### Configure WP Rocket

If you use WP Rocket, make sure specific settings are unchecked.

1. In your WordPress dashboard, go to **Settings** > **WP Rocket**.

2. Open the **File Optimization** tab.

   ![WP Rocket settings with an arrow pointing to the File Optimization tab in the left menu](https://mintcdn.com/cometly/2fSDFk1g6ELl9hsV/images/integrations/pixel/wordpress/01.webp?fit=max\&auto=format\&n=2fSDFk1g6ELl9hsV\&q=85\&s=9a55f3190a72dad73f4f727a34c16d25)

3. Scroll down to the **JavaScript Files** section and make sure these options are unchecked:

   * **Combine JavaScript files**
   * **Load JavaScript deferred**
   * **Delay JavaScript execution**

   ![WP Rocket JavaScript Files section with arrows on Load JavaScript deferred and Delay JavaScript execution](https://mintcdn.com/cometly/2fSDFk1g6ELl9hsV/images/integrations/pixel/wordpress/02.webp?fit=max\&auto=format\&n=2fSDFk1g6ELl9hsV\&q=85\&s=33a023e23672e5fea7cc26cbbd9ec61a)

4. Click **Save Changes**, then clear your cache.

If you use other performance or header management plugins, check their documentation for similar settings so they do not interfere with JavaScript loading. See also [Delayed JavaScript execution or lazy loading](https://docs.cometly.com/support/troubleshooting/pixel/delayed-javascript-or-lazy-loading.md).

## Check it worked

In Cometly, open **Setup** step 2, **Install the Cometly pixel**. Under **Verify your pixel**, click **Verify** next to your WordPress domain: it should show **Pixel detected**. If it shows **Pixel not detected**, clear your cache, check the plugin settings above, then click **Retry**.

## Frequently asked questions

### Why is the Cometly pixel not detected on my WordPress site?

The usual causes are a cached copy of the page that does not include the pixel yet, or a plugin that defers, delays or lazy-loads JavaScript. Clear your cache, turn those JavaScript options off, and make sure the script in your site's `<head>` matches the one Cometly shows under **Install the pixel**.

### Can I add the Cometly pixel to WordPress with Google Tag Manager?

Yes, the pixel works when it is installed through Google Tag Manager, but you may lose attribution data because of loading delays and privacy blockers. Installing it directly in the `<head>` section is recommended. Do not do both, because the pixel then loads twice and causes tracking issues.

### Do I need to update the pixel on WordPress after changing settings in Cometly?

Yes, in some cases. The script changes when you add or remove domains, or change a setting under **Pixel options**. If Cometly tells you your tracking script has changed, copy it again and replace the old one on your site, then clear your cache.

## Next steps

* [Install and verify the Cometly pixel](https://docs.cometly.com/getting-started/install-pixel.md)
* [Check your pages with the Cometly Pixel Helper](https://docs.cometly.com/guides/tracking/pixel-helper.md)
* [Fix delayed JavaScript execution or lazy loading](https://docs.cometly.com/support/troubleshooting/pixel/delayed-javascript-or-lazy-loading.md)
* [Set up the WooCommerce integration](https://docs.cometly.com/integrations/platforms/woocommerce.md)
* [Install the pixel with Google Tag Manager](https://docs.cometly.com/integrations/pixel/google-tag-manager.md)

Still have questions or need a hand? We're happy to help. Reach our team at [support@cometly.com](mailto:support@cometly.com).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.