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 targetingFromCache()
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, we recommend calling
targeting
to update the local cache on every 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.