Report conversions for advertisers
For Rokt advertisers, the Android SDK can record conversion events that occur in your app to help you close the loop on your campaigns.
Before you begin
Ensure that the Rokt Android SDK has already been integrated into your application following the steps listed here.
Executing the Rokt Android SDK
Execute the SDK in your desired activity/fragment by adding any appropriate customer attributes and the placement mapping. The example code uses the onCreate
method to report conversions.
You can dictate what customer attributes are shared with Rokt. More information on available data fields can be found on the attributes page. If you want to share more attributes, you can add additional lines of code for each new attribute to the samples below.
The Rokt Android SDK is also used to integrate Rokt placements into partner applications. There are optional callbacks available in the SDK when displaying Rokt placements. However, as this guide is specifically referring to recording conversion events, you can ignore the callbacks.
- Java
- Kotlin
import com.rokt.roktsdk.Rokt
class ConfirmationActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
// Include any appropriate consumer attributes
val attributes = hashMapOf(
Pair("email", "j.smith@example.com"),
Pair("firstname", "Jenny"),
Pair("lastname", "Smith"),
Pair("mobile", "(323) 867-5309"),
Pair("postcode", "90210"),
Pair("country", "US"))
Rokt.execute("RoktExperience",
attributes,
object : Rokt.RoktCallback {
override fun onUnload(reason: Rokt.UnloadReasons) {
}
override fun onLoad() {
}
override fun onShouldHideLoadingIndicator() {
}
override fun onShouldShowLoadingIndicator() {
}
}
)
...
}
}
import com.rokt.roktsdk.Rokt;
class ConfirmationActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
Map<String,String> attributes = new HashMap<String, String>();
attributes.put("email", "j.smith@example.com");
attributes.put("firstname", "Jenny");
attributes.put("lastname", "Smith");
attributes.put("mobile", "(323) 867-5309");
attributes.put("postcode", "90210");
attributes.put("country", "US");
Rokt.INSTANCE.execute("RoktExperience",
attributes,
new Rokt.RoktCallback() {
@Override
public void onLoad() {
}
@Override
public void onUnload(Rokt.UnloadReasons unloadReasons) {
}
@Override
public void onShouldHideLoadingIndicator() {
}
@Override
public void onShouldShowLoadingIndicator() {
}
}
)
...
}
}