How to show ads based on the cookie consent

This guide provides a detailed overview of how Advanced Ads can manage ad injection based on cookie consent. It intuitively integrates with most consent-gathering methods, including readable cookies and the TCF 2.2 consent framework, to respect users’ preferences.

I’ve included a comprehensive table outlining popular cookie consent plugin configurations to simplify your setup.

You’ll also learn how to display non-personalized AdSense ads without explicit consent, implement fallback ads for non-consent scenarios, and determine when this approach benefits your site.

In online advertising, consent means the explicit permission given by website visitors to collect, process, and store their data. Privacy laws like the General Data Protection Regulation (GDPR) and the California Consumer Privacy Act (CCPA) require websites to obtain this permission before using cookies to track user behavior, preferences, or other personal information.

A consent cookie is a tool for recording and managing these permissions. When users visit a website, they typically encounter a cookie banner explaining the types of cookies used and their purposes. Users can choose to accept or decline cookies.

If a user grants consent, a cookie is stored on his device to record this decision. It’s a tiny text file under the control of the user and managed by their browser. This cookie helps guide future interactions between the user’s device and the website, including whether and when ads will appear. 

By using consent cookies, websites ensure compliance with privacy regulations and respect user choices when displaying advertisements.

To set up ads based on cookie consent, enable the Privacy module in the first step under Advanced Ads > Settings >  Privacy.

When you activate the Privacy module and select a consent method in Advanced Ads, all ads except ads using the Image ad type will be hidden by default until visitors explicitly grant their consent. 

I describe how to define exceptions from this rule later in this manual. 

Advanced Ads Privacy module

However, configuring your ad setup to show ads based on cookie consent means that if consent is not granted, neither you nor any other user will see ads, starting immediately after enabling this feature. Therefore, enabling this setting may reduce your ad revenue.

Consent methods

After enabling the Privacy module, you must choose your preferred consent method. You can decide whether to always show all ads—even without consent—or based on a specific consent cookie value. Additionally, here you can set to show ads based on TCF 2.2 consent.

The privacy settings apply only to ads managed through Advanced Ads. They do not affect ad codes you’ve manually added to your site. However, you can use these settings to control the display or execution of any other code requiring prior consent.

Advanced Ads does not automatically generate a consent notice. However, you can create a custom consent notice for GDPR compliance and integrate it with Advanced Ads explained in this tutorial

Show ads even without consent

If you enable this setting, Advanced Ads will deliver all ads as usual without checking for cookie consent. This option is handy for debugging or adjusting an existing ad setup, as it lets you temporarily bypass the cookie consent check with a single click. Once you’ve made the necessary changes, you can easily switch back to the cookie consent method.

For long-term use, bypassing the cookie consent check makes little sense. If you’re serving all ads regardless of consent, you might as well deactivate the Privacy module entirely.

Cookie

The Cookie setting allows you to display ads based on the presence of a specific cookie. Advanced Ads will hide these ads until the user accepts the specified cookie. The cookie only needs to contain the defined value — it doesn’t have to be an exact match. However, the value field cannot be left empty; a value is necessary for the check to work.

For example, if you’re using Complianz as your cookie consent plugin and want to show ads only to users who have consented to marketing cookies, the entry would look like this:

Example for Complianz:

Cookie: cmplz_marketing

Value: allow

A dedicated section of this manual contains a table with popular plugins and their corresponding cookie values.

Show non-personalized AdSense ads

Advanced Ads allows you to display non-personalized AdSense ads when users don’t grant consent.

According to AdSense policy, you must obtain consent from EU visitors to use cookies and personalized ads. Personalized ads rely on historical or previously collected data—such as search history, site visits, location, or demographic information—to influence ad selection. In contrast, non-personalized ads do not use cookies or mobile identifiers for targeting.

Opinions differ on whether consent is needed to implement non-personalized ads. While some believe it’s enough to inform visitors, others suggest obtaining explicit consent. To accommodate this, Advanced Ads provides an option to show non-personalized AdSense ads even when users haven’t consented.

This setting applies only to AdSense ads added via the AdSense ad type. It does not affect ads inserted using the Plain text and code ad type.

It is your responsibility to determine whether this approach complies with current local regulations. Future changes in Google’s policies may affect how this feature works.

Show non-personalized AdSense ads
Important consideration

The Advanced Ads option will no longer apply if you turn off personalized ads for all EU visitors directly in your AdSense account. In that case, all EU visitors—regardless of consent—will see non-personalized ads by default.

To adjust this setting in your AdSense account:

  1. Go to Privacy & messaging.
  2. Open Consent management solutions.
  3. Update your preferences to meet regulatory requirements.

For verification, follow this tutorial to ensure that non-personalized ads are displayed correctly.

The “Non-personalized ads for AdSense” option doesn’t work for Auto ad codes added manually to the website (and not through Advanced Ads’ AdSense settings).

Show ads based on TCF 2.2 consent

The Transparency & Consent Framework (TCF) 2.2 ensures compliance with privacy laws like GDPR by standardizing how consent is collected and shared between publishers, CMPs (Consent Management Platforms), and vendors like ad networks. If you use a TCF 2.2-compatible CMP, Advanced Ads integrates comfortably to ensure ads are displayed based on user consent.

Cookie consent options in Advanced Ads
Cookie consent options

Advanced Ads connects your CMP and vendors, ensuring that ad codes load only if the user consents. This integration automatically respects user preferences.

The TCF 2.2 Consent Manual for WordPress provides detailed step-by-step instructions for setting up TCF 2.2 with Advanced Ads. If you have further questions, feel free to contact our support team.

Sometimes, you might want to display ads that don’t rely on user consent, such as custom HTML ads that don’t load external code. To enable this, navigate to the ad edit screen of the relevant ad, find the Ad Parameters box, and check the “Ignore general privacy settings” option. This functionality is available only if the Privacy module is active and the selected ad type qualifies for optional consent handling.

Optional exceptions from the cookie consent settings for individual ads
Optional exceptions from the global consent settings for individual ads

For example, image ads usually don’t require consent unless you’ve added custom code in the Custom Code field provided by Advanced Ads Pro. Consent becomes mandatory when you use this field and insert any code there. Conversely, AdSense ads always require user consent and cannot bypass privacy settings made through the ad edit screen.

By default, the following ad types wait for consent before displaying unless the “Ignore general privacy settings” option is enabled:

  • Plain text and code ads
  • Rich content ads
  • AdSense ads
  • Google Ad Manager ads
  • Auto ads configured through Advanced Ads > Settings > AdSense
  • Image ads when the Custom Code option is used

Fallback ads to monetize pageviews while respecting privacy

If you only display ads after user consent, it’s possible to have ad-free page views from users who don’t grant permission. To avoid this, use the opt-out option mentioned earlier to set up a fallback ad, as described in this tutorial.

For example, you could display image ads featuring affiliate marketing banners or use simple affiliate text links. These ad formats don’t typically require user consent if they don’t involve tracking or external scripts, allowing you to monetize traffic even when users did not grant permission.

This approach ensures that ads requiring consent are only displayed once a user consents, while privacy-compliant fallback ads serve as a backup for users who decline consent.

Advanced Ads offers a flexible cookie consent method that smoothly integrates with the most popular consent plugins and solutions. Below are examples of commonly used plugins and the corresponding settings you need to configure.

PluginCookie NameCookie Value
Borlabs Cookies 2.X,3.Xborlabs-cookieplease find the detailed instructions below
Complianz 7.Xcmplz_marketing allow
Cookie banner plugin for WordPress – Cookiebot CMP by UsercentricsCookieConsentmarketing:true
CookieFirstcookiefirst-consent\”advertising\”:true
Cookie Notice & Compliance for GDPR / CCPAcookie_notice_acceptedtrue
CookieProOptanonConsent 0004:1 (1=accepted)
CookieYes – Cookie Banner for Cookie Consentcookieyes-consentadvertisement:yes
GDPR Cookie Compliancemoove_gdpr_popupthirdparty
TermlycatAccCookies1
Names and values of different GDPR cookie consent solutions for WordPress

You can build your custom cookie consent message for WordPress following this tutorial.

If you need a more advanced cookie check than the privacy consent option provides, use our ad-specific Cookie condition instead of the privacy settings above.

Borlabs Cookie versions 2.x and 3.x store the IDs of cookie groups and individual cookies. You can use these IDs in Advanced Ads to control when to display those ads.

Configuration examples
  • Show ads when the “Marketing” group is accepted: Enter marketing in the cookie value field in Advanced Ads.
  • Show ads when users consent to Google AdSense cookies: Enter google-adsense in the cookie value field in Advanced Ads.
cookie-based ad condition
Example: settings to show an ad unit only when the cookie group “marketing” is accepted
Important note for AdSense users

If you use the Advanced Ads privacy feature to embed AdSense ads on your site, disable the AdSense cookie from Borlabs Cookie. You can do this in Dashboard > Borlabs Cookie > Cookies.

Disabling the AdSense integration from Borlabs Cookie
Turn off the AdSense cookie in Borlabs if you use the privacy function of Advanced Ads.

Tip: If you have an active All Access license, check the Deals section of your Advanced Ads account for a discount on Borlabs Cookie.

Integrating with Complianz

Complianz saves a cookie you can use to show ads after consenting. The cookie is cmplz_marketing for Complianz 7+. When a user consents, the cookie contains the value “allow.”

To avoid potential issues, please refrain from connecting Complianz with Advanced Ads under Dashboard > Complianz > Integrations > Plugins. Similarly, avoid connecting Complianz with Advertisements under Dashboard > Complianz > Integrations > Services.

Complianz privacy settings
Options to integrate Complianz with different services and plugins

The premium version of Complianz also supports the TCF 2.2 standard. For more information, see this manual on integrating TCF 2.2 using Advanced Ads.

Tip: If you have an active All Access license, you can find a discount for Complianz Premium in the Deals section of your account.

Integrating with other services

Didomi

If you use Didomi as a consent management tool, you must rewrite the ad codes managed by Advanced Ads as described here.

Ad health warning

If you enable the Ad Health module and consent method but do not give consent, you might see a warning in the Ad Health section on your frontend’s admin bar. This warning is not an error but a helpful debug tool to identify why ads may not appear. Don’t worry—only you can see this message and this warning disappears once you grant consent.

AMP compatibility

This feature is currently not compatible with AMP. The Google AMP bot may cache a version of the page without ads, preventing them from being displayed. We will address this limitation as soon as any cookie consent plugins that integrate with Advanced Ads offer AMP support. 

Caching 

To display ads dynamically based on user consent on cached websites, you need Advanced Ads Pro with the cache busting feature enabled.

Without cache busting, caching mechanisms may serve incorrect ads to users, as all visitors see the same cached content. The cache busting functionality solves this issue.

In our tests, WP Rocket handled cache busting particularly well.

Correct cookie values

If cookie values include special characters such as single quotes ('), double quotes ("), or backslashes (\), they must be escaped with a backslash (\) for the privacy feature to read them correctly.

Example:
Cookie value: "ads"
Correct entry: \"ads\"

    Make it better

    Increase your ad management skills without spending more time.
    Join over 150,000 publishers and AdOpts increasing their ad revenue.