Example: targeting API: GAM360 (cached data)

Shows how to load and cache active cohorts in a visitor's browser. Separately, cached cohorts are passed to Google Ad Manager (GAM) via the Google Publisher Tag (GPT) for ad targeting.

In this example, we use the targetingKeyValuesFromCache() API to retrieve any targeting data from browser LocalStorage, in order to pass it to GPT via googletag.pubads().setTargeting(). We also call the SDK targeting API which will fetch the latest targeting data from our DCN and cache it locally for later use. Since these two events happen asynchronously, it's possible that the targeting data passed to GAM is slightly outdated. To ensure ad targeting accuracy, it is recommended to call targeting to update the local cache on page load.

If you are comfortable with disabling initial load on GAM ads and always loading them explicitly with the very latest targeting data, have a look at the original targeting & GAM360 activation example instead.

web-sdk-demo-gam360/header-ad
web-sdk-demo-gam360/box-ad
web-sdk-demo-gam360/footer-ad