Stay organized with collections
Save and categorize content based on your preferences.
Display a limited ad
This is an example of using the Google Publisher Tag (GPT) library to request
and render a limited ad. Limited ads provide publishers a way to serve ads in
the absence of consent for the use of cookies or other local identifiers. Learn
more about the features and limitations of limited ads in the
Google Ad Manager help center.
In order to manually control limited ads, you must load GPT from the
limited ads URL. The version of GPT served from
this URL contains additional safeguards against accessing client-side storage by
default. To accomplish this, certain library operations are delayed until after
the first call to display(), leading to a slight decrease in performance
compared to the standard version of GPT.
You can't manually control limited ads on a per-request basis when GPT is loaded
from the standard URL. When you load GPT from the standard URL, all calls to
setPrivacySettings({ limitedAds: ... }) are ignored and the library may
attempt to access client-side storage at any time. This allows GPT to more
effectively optimize the order of library operations. For example, GPT can
perform secure signal collection earlier,
increasing the likelihood that gathered signals will be included in every ad
request.
[null,null,[],[],[],null,["# Display a limited ad\n====================\n\nThis is an example of using the Google Publisher Tag (GPT) library to request\nand render a limited ad. Limited ads provide publishers a way to serve ads in\nthe absence of consent for the use of cookies or other local identifiers. Learn\nmore about the features and limitations of limited ads in the\n[Google Ad Manager help center](//support.google.com/admanager/answer/9882911).\n\nYou can instruct GPT to request limited ads in\n[two different ways](//support.google.com/admanager/answer/9882911#implementation):\n\n- Automatically, by using a signal from an [IAB TCF v2.0](//iabeurope.eu/tcf-2-0/) consent management platform (CMP).\n- Manually, by using the [GPT `PrivacySettings` API](//developers.google.com/publisher-tag/reference#googletag.privacysettingsconfig).\n\n| **Important:** it is not necessary to manually enable limited ads when a CMP is in use.\n\nIn order to manually control limited ads, you must load GPT from the\n[limited ads URL](//developers.google.com/publisher-tag/guides/general-best-practices#load_from_an_official_source). The version of GPT served from\nthis URL contains additional safeguards against accessing client-side storage by\ndefault. To accomplish this, certain library operations are delayed until after\nthe first call to `display()`, leading to a slight decrease in performance\ncompared to the standard version of GPT.\n\nYou can't manually control limited ads on a per-request basis when GPT is loaded\nfrom the standard URL. When you load GPT from the standard URL, all calls to\n`setPrivacySettings({ limitedAds: ... })` are ignored and the library may\nattempt to access client-side storage at any time. This allows GPT to more\neffectively optimize the order of library operations. For example, GPT can\nperform [secure signal](//support.google.com/admanager/answer/10488752) collection earlier,\nincreasing the likelihood that gathered signals will be included in every ad\nrequest.\n\nSample implementation\n---------------------\n\n[View demo](https://googleads.github.io/google-publisher-tag-samples/display-limited-ad/js/demo.html) \n\n### JavaScript\n\nLoading...\n----------\n\nLoading...\n----------\n\n[Improve this sample](https://github.com/googleads/google-publisher-tag-samples/tree/main/dist/display-limited-ad/js) [Report an issue](https://github.com/googleads/google-publisher-tag-samples/issues/new?labels=documentation&template=sample-feedback.md&title=Sample+feedback%3A+display-limited-ad/js)\n\n### TypeScript\n\nLoading...\n----------\n\nLoading...\n----------\n\n[Improve this sample](https://github.com/googleads/google-publisher-tag-samples/tree/main/dist/display-limited-ad/ts) [Report an issue](https://github.com/googleads/google-publisher-tag-samples/issues/new?labels=documentation&template=sample-feedback.md&title=Sample+feedback%3A+display-limited-ad/ts)"]]