Note that this sample includes several build flavors. Developers should use the "preview" flavor when compiling and installing the app. For OEMs to use the required build flavor, you will need to specify "oem" when compiling and installing. All other instructions in this README are the same regardless of what flavor is used.
The Measurement sample app showcases how to use the Attribution Reporting API
- Initializes a
MeasurementManager
client inAppModule
- Provides two buttons to register the source event from
SourceFragment
viaregisterSource
- when user clicks
Register Click Event
, the click event is registered. - when user clicks
Register View Event
, the view event is registered.
- when user clicks
- Provides a button to register trigger event from
TriggerFragment
viaregisterTrigger
- when user clicks
Register Trigger
, the action is registered.
- when user clicks
To test functionality of the Attribution Reporting API, you need to set up your development environment. This process involves installing the proper SDK and the device images needed to test functionality on an emulator.
The Attribution Reporting API sends event reports to the configured server. We can easily configure the Server URL from the options menu on the top right side of the app.
- Configure Server URL from the options menu
- On the app and click
Register Click Event
button - Switch tabs and click
Register Trigger
button - Force AttributionJobService
adb shell cmd jobscheduler run -f com.google.android.adservices.api 5
- Open phone time & date settings. Disable automatic time & date. Then set the date 3 days forward.
- Force ReportingJobService
adb shell cmd jobscheduler run -f com.google.android.adservices.api 3
adb shell cmd jobscheduler run -f com.google.android.adservices.api 7
You can verify server interactions by examining the request/response logs of the configured server.
For a full overview of how Attribution Reporting works, read the design proposal. Review the developer guide for details on API usage and systems integration.