Sending Ad Revenue on Android

Testing and manually sending purchase information

AppMetrica doesn't let you segment Ad Revenue into "test" and "not test". If you use the main API key for debugging the collection of data on advertising monetization, the test events are included in general statistics. If you need to debug sending Ad Revenue, use a reporter to send statistics to an additional API key.

Step 1. Create a test app in AppMetrica

Specify the app parameters: link in the app store (if the app hasn't been published yet, leave the field empty), name, category, and time zone for generating reports.

To add another app, click Add app in the drop-down list in the AppMetrica interface.

Step 2. Test sending Ad Revenue

This section outlines the steps for sending Ad Revenue to the additional API key:

  1. Create an AdRevenue instance using the AdRevenue.Builder.

    Map<String, String> adRevenuePayload = new HashMap<>();
    adRevenuePayload.put("payload_key_1", "payload_value_1");
    adRevenuePayload.put("payload_key_2", "payload_value_2");
    AdRevenue adRevenue = AdRevenue.newBuilder(new BigDecimal("100.100"), Currency.getInstance("USD"))
    .withAdNetwork("ad_network")
    .withAdPlacementId("ad_placement_id")
    .withAdPlacementName("ad_placement_name")
    .withAdType(AdType.NATIVE)
    .withAdUnitId("ad_unit_id")
    .withAdUnitName("ad_unit_name")
    .withPrecision("some precision")
    .withPayload(adRevenuePayload)
    .build();
    
  2. Send the AdRevenue instance to the test API key using IReporter. For more information about reporters, see Usage examples.

    AppMetrica.getReporter(TEST_API_KEY).reportAdRevenue(adRevenue);
    

Step 3. Make sure that Ad Revenue info is shown in reports.

  1. View ads in the app.

  2. Make sure that the Revenue report shows the same number of Ad Revenue events as the number of ad views.

Step 4. Set up sending Ad Revenue to the main API key

  1. Make sure that the SDK is activated before sending data to the main API key. Activation example:

    AppMetricaConfig config = AppMetricaConfig.newConfigBuilder(API_KEY).build();
    AppMetrica.activate(context, config);
    
  2. After debugging, repeat steps 2 and 3 for the main API key.

  3. To send the AdRevenue instance to the main API key, use the AppMetrica.reportAdRevenue(AdRevenue adRevenue) method.

    AppMetrica.reportAdRevenue(adRevenue);
    

If you didn't find the answer you were looking for, you can use the feedback form to submit your question. Please describe the problem in as much detail as possible. Attach a screenshot if possible.

Contact support