When to Use the Advertising ID
You must use the Advertising ID (when supported by the device) and verify a user’s opt-out choice via API, if your app does the following:- Displays interest-based ads
- Collects data for user analytics
- Collects data to build user profiles for advertising purposes or for targeting users with interest-based advertising
How to Use the Advertising ID
When you use the Advertising ID, follow these requirements:- Only use the Advertising ID for interest-based ads and analytics.
- In your code, precede any call to retrieve the Advertising ID with a call that verifies the user’s opt-out choice. When the user opts out of interest-based ads, the Advertising ID is still available but the developer must honor the user’s opt-out choice. Do not collect information about the user’s behavior to build user profiles for advertising purposes or show them interest-based ads. Allowed activities include contextual advertising, frequency capping, conversion tracking, reporting, and security and fraud detection.
- Do not associate any persistent device identifier or personally-identifiable information (PII) with the Advertising ID unless the user has explicitly given consent to do so.
- When a user resets the Advertising ID, do not fold earlier data into the new Advertising ID or associate the new ID with the old one unless the user has explicitly given consent for you to do so.
Verifying and Responding to the User’s Advertising ID Choices
The Android Settings.Secure class exposes the user’s Advertising ID choices through the getInt and getString methods. The following Java example shows the logic for verifying the user setting and retrieving an Advertising ID (if available).- If the user has allowed ad tracking, the value for
limit_ad_trackingwill befalse. - If the user has disabled ad tracking, the value for
limit_ad_trackingwill betrue. - The Advertising ID gets stored in the
advertisingIDvariable. A sample Advertising ID value might bedf07c7dc-cea7-4a89-b328-810ff5acb15d. (For child profiles, theadvertisingIDwill be00000000-0000-0000-0000-00000000000.) - If the system doesn’t return any value for
limit_ad_tracking(such as for non-Fire-OS devices or Fire Devices running older versions of Fire OS), aSettingNotFoundExceptiongets thrown. You can handle this exception as desired.

