How to retrieve Advertising ID in Vega

Advertising ID (Ad ID) is commonly used in various apps, especially in AVOD (Advertising Video On Demand) apps. Ad ID is used to show customized ads for specific customers and/or devices. Given Ad ID is used for privacy related features, it is important to provide opt-out mechanism for end users. In this KB, we will explain how to retrieve an Ad ID and opt-out status on Vega. We will also explain conditions for testing AdIdRetriever on Vega FTV devices.

Important note : AdIdRetriever is ONLY supported on the Vega FTV device . If you try to run this on the simulator, AdIdRetriever.isAdvertisingTrackingEnabled() returns false always.

Steps to integrate

  1. Add the following library in the “dependencies” section to package.json.
  "dependencies": {
    "@amzn/kepler-adid-retriever": "^1.0.9"
  }
  1. Add Package ID to manifest.toml.
[wants]
[[wants.service]]
id = "com.amazon.admanager.service.main"
  1. Import AdIdRetriever in your code.
import {AdIdRetriever} from '@amzn/kepler-adid-retriever';
  1. Retrieve AdID in your code.
  if (AdIdRetriever.isAdvertisingTrackingEnabled()) {
    const adId: string = AdIdRetriever.fetchAdvertisingId();
    console.log(`Interest-based Ads is enabled. Retrieved AdID: ${adId}`);
  } else {
    console.log(`Interest-based Ads is disabled.`);
  }
  1. Build and run your project. With the sample code above, you’ll see the console.log messages using loggingctl (see details in Use Loggingctl to Manage System Logs | Vega CLI Tools)

Testing Conditions

  1. Go to Settings > Preferences > Privacy Settings > Interest-based Ads. Change it On or Off to test AdIdRetriever.isAdvertisingTrackingEnabled()
  2. Check the Ad ID under the Privacy Settings to test AdIdRetriever.fetchAdvertisingId()
  3. You can also reset Ad ID on the Ad ID setting.
1 Like