- Retrieve the advertising ID for bidding, reporting impressions, and reporting attributions of ads. (
fetchAdvertisingId) - Retrieve a user’s preference on interest-based advertisements. (
isAdvertisingTrackingEnabled)
Behavior
Account for the following when you integrate Ad ID Retriever.- Verify tracking before you use the advertising ID. Call
isAdvertisingTrackingEnabledand check the result before you use the value fromfetchAdvertisingIdfor interest-based advertising. If it returnsfalse, the user has opted out of interest-based advertising, so serve contextual (non-personalized) advertisements rather than interest-based ones. - Child profiles. On a child profile,
isAdvertisingTrackingEnabledreturnsfalseregardless of the Interest-based Ads setting. The user has opted out of interest-based advertising, so serve contextual (non-personalized) advertisements rather than interest-based ones. - Service unavailable.
fetchAdvertisingIdreturns an empty string if it cannot reach the Advertising Manager service. This does not raise an error. An empty string means the Advertising Manager service was unreachable. Do not use an empty string as a valid advertising ID.
Get Started
Setup
- Add the following library dependency to the
dependenciessection of your package.json file.
-
In your manifest.toml, add the following components and wants required to access Ad ID Retriever.
Usage
This example demonstrates how to implement the Ad ID Retriever service. The example provides a simple UI with two buttons that showcases both core functionalities: fetching the advertising ID and checking the advertising tracking status.API Reference
Classes
- AdIdRetriever — AdIdRetriever provides APIs for retrieving advertising IDs and advertising tracking state.

