Ingresos por anuncios
Reportes de ingresos por publicidad a nivel de impresiones por SDK
The app sends impression revenue data to the SDK which then sends it to AppsFlyer. The revenue data is collected and processed in AppsFlyer, and the revenue is attributed to the original UA source. To learn more about ad revenue see here.
There are two ways for the SDK to generate an ad revenue event, depending on your SDK version. Use the correct method for your SDK version:
- For SDK 6.15.0 and above. Uses the ad revenue SDK API.
- For SDK 6.14.2 and below. Uses the ad revenue SDK connector.
Log ad revenue (for SDK 6.15.0 and above)
When an impression with revenue occurs, invoke the logAdRevenue
method with the revenue details of the impression.
To implement the method:
- Create an instance of
AFAdRevenueData
with the revenue details of the impression to be logged.Version 6.15.0 of the SDK removes the need for using a connector for sending Ad Revenue data to AppsFlyer. - If you want to add additional details to the ad revenue event, populate a map with key-value pairs.
- Invoke the
logAdRevenue
method with the following arguments:- The
AFAdRevenueData
object you created in step 1. - The
Map
instance with the additional details you created in step 2.
- The
Code Example
import com.appsflyer.AFAdRevenueData;
import com.appsflyer.MediationNetwork;
import com.appsflyer.AppsFlyerLib;
import java.util.HashMap;
import java.util.Map;
AppsFlyerLib appsflyer = AppsFlyerLib.getInstance();
// Create an instance of AFAdRevenueData
AFAdRevenueData adRevenueData = new AFAdRevenueData(
"ironsource", // monetizationNetwork
MediationNetwork.GOOGLE_ADMOB, // mediationNetwork
"USD", // currencyIso4217Code
123.45 // revenue
);
Map<String, Object> additionalParameters = new HashMap<>();
additionalParameters.put(AdRevenueScheme.COUNTRY, "US");
additionalParameters.put(AdRevenueScheme.AD_UNIT, "89b8c0159a50ebd1");
additionalParameters.put(AdRevenueScheme.AD_TYPE, "Banner");
additionalParameters.put(AdRevenueScheme.PLACEMENT, "place");
appsflyer.logAdRevenue(adRevenueData, additionalParameters);
Nota
The AdMob iLTV SDK reports impression revenue in micro-units. To display the correct ad revenue amount in USD in AppsFlyer, divide the amount extracted from the iLTV event handler by 1 million before sending it to AppsFlyer.
[LEGACY] Log ad revenue (for SDK 6.14.2 and below)
For SDK v6.14.2 and below - the AdRevenue Connector should be used along side the AppsFlyer SDK to send Ad Revenue data to AppsFlyer.
Import the Android ad revenue SDK
- Agrega el siguiente código a Module-level /app/build.gradle antes de las dependencias:
repositories {
mavenCentral()
}
- Agrega la biblioteca de ingresos por publicidad como dependencia:
dependencies {
implementation 'com.appsflyer:adrevenue:6.9.0'
}
- Sincroniza el proyecto para recuperar las dependencias.
Initialize the Android ad revenue SDK
- En la clase global de la aplicación, dentro del método
onCreate
, llama ainitialize
, e introduce el siguiente código:
import com.appsflyer.adrevenue.AppsFlyerAdRevenue;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
AppsFlyerAdRevenue.Builder afRevenueBuilder = new AppsFlyerAdRevenue.Builder(this);
AppsFlyerAdRevenue.initialize(afRevenueBuilder.build());
}
}
Trigger the logAdRevenue API call
- Activa la llamada a la API
logAdRevenue
luego de cada impresión válida, incluidos los argumentos obligatorios y opcionales.
// Make sure you import the following:
import com.appsflyer.adrevenue.adnetworks.AppsFlyerAdNetworkEventType;
import com.appsflyer.adrevenue.adnetworks.generic.MediationNetwork;
import com.appsflyer.adrevenue.adnetworks.generic.Scheme;
import java.util.Currency;
import java.util.HashMap;
import java.util.Locale;
// Create optional customParams
Map<String, String> customParams = new HashMap<>();
customParams.put(Scheme.COUNTRY, "US");
customParams.put(Scheme.AD_UNIT, "89b8c0159a50ebd1");
customParams.put(Scheme.AD_TYPE, "Banner");
customParams.put(Scheme.PLACEMENT, "place");
customParams.put(Scheme.ECPM_PAYLOAD, "encrypt");
customParams.put("foo", "test1");
customParams.put("bar", "test2");
// Record a single impression
AppsFlyerAdRevenue.logAdRevenue(
"ironsource",
MediationNetwork.googleadmob,
Currency.getInstance(Locale.US),
0.99,
customParams
);
Actualizado hace 2 meses