How to block pixel tracking from image sources

Get compliant today in the European Union, United States, Canada, United Kingdom, Australia, Brazil & South Africa with the only Privacy Suite for WordPress that offers a fully-featured plugin for Worldwide Compliance.

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 “awin1.com”. 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

Recent articles

Integration with Woodmart Google Maps

An integration with the WoodMart theme is available as an MU Plugin on GitHub: https://github.com/Really-Simple-Plugins/complianz-integrations/blob/master/woodmart-custom-google-maps.php

Read More »
The Privacy Suite for WordPress
Get compliant today with the only Privacy Suite made for WordPress

Categories

Popular articles

Join our mailing list - 8 Tips & Tricks in your inbox over the next 8 weeks!