Close this search box.


In this article



Recent articles

How to block pixel tracking from image sources

If you include images/graphics on your site that track user data, these will have to be blocked prior to consent from your website visitors; just like other tracking scripts.

The image displayed in the below screenshot results in multiple third-party cookies being set without prior consent:

Complianz - Block tracking images and pixels

Complianz contains a filter that blocks such tracking images and pixels, which we recommend implementing as an MU Plugin (alternatively, by inserting the code in the functions.php of your theme). We will detail how this filter should be implemented.

1. Copy the code

Copy the code below, and place it in a new .php file.

2. Find the image source to block

We have to find the source of the tracking image that should be blocked by Complianz.

You can do this with the Developer Tools in your browser, by right-clicking the image and selecting “Inspect Element”. This will reveal the URL where the image is being loaded from.

Complianz - Find URL of tracking images and pixels

In the above example, we’ve discovered that our image is loaded from “”. This is what we will have to use as the URL to block in our filter/MU Plugin.

3. Adjust the code to block the image source

Now that we have the URL of the image that has to be blocked, we can adjust the filter from step 1 to block this image.

Enter the URL of your image to block on line 12 of the filter, between the single quotes.

The end result, when we apply the URL from the example screenshot above, will be:

4. Apply the filter to your website

Save your new filter as a .php file, then upload it to the folder /wp-content/mu-plugins/ on your website to take effect (for detailed instructions on installing MU Plugins, please see this article.)

The result will be a blocked image, which prevents it from tracking user data or setting cookies without consent.

Complianz - Blocked tracking image/pixel with PHP filter

Join 900.000 users and install The Privacy Suite for WordPress locally, automated or fully customized, and access our awesome support if you need any help!

Complianz has received its Google CMP Certification to conform to requirements for publishers using Google advertising products.