Integrate with sandbox (legacy)
With a sandbox integration, you can include a configuration flag to test against a sandbox environment. The sandbox environment follows a normal offers, bidding, and matching process against your production configuration. While a sandbox environment is part of the Rokt production environment, it does not charge advertisers or generate revenue. As a result, you can use it for acceptance testing before deploying to production.
The integration follows exactly the same steps as in previous examples, with an additional sandbox attribute required in the selectPlacements function.
You must remove the sandbox attribute before going live with your placement.
Overlay placement exampleDirect link to Overlay placement example
To run an overlay placement in the sandbox environment, the list of attributes passed to Rokt needs to be updated to include "sandbox": "true". This can be done by updating the code from the example in the adding an overlay placement documentation to include the following:
- 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("sandbox", "true"),
Pair("firstname", "Jenny"),
Pair("lastname", "Smith"),
Pair("mobile", "(323) 867-5309"),
Pair("postcode", "90210"),
Pair("country", "US"))
Rokt.selectPlacements(
identifier = "RoktExperience",
attributes = attributes,
onEvent = { roktEvent ->
// Handle Rokt events
}
)
...
}
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("sandbox", "true");
attributes.put("firstname", "Jenny");
attributes.put("lastname", "Smith");
attributes.put("mobile", "(323) 867-5309");
attributes.put("postcode", "90210");
attributes.put("country", "US");
Rokt.INSTANCE.selectPlacements("RoktExperience",
attributes,
roktEvent -> {
// Handle Rokt events
}
)
...
}
}
Embedded placement exampleDirect link to Embedded placement example
To run an embedded placement in the sandbox environment, you need to update the list of attributes passed to Rokt to include "sandbox": "true". This can be done by updating the sample code from the adding an embedded placement documentation to include the following:
- Java
- Kotlin
import com.rokt.roktsdk.Widget
import com.rokt.roktsdk.Rokt
class ConfirmationActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
...
// Include any appropriate consumer attributes
val attributes = hashMapOf(
Pair("email", "j.smith@example.com"),
Pair("sandbox", "true"),
Pair("firstname", "Jenny"),
Pair("lastname", "Smith"),
Pair("mobile", "(323) 867-5309"),
Pair("postcode", "90210"),
Pair("country", "US")
)
// Widget placeholder mapping the placeholder view with placement location configuration
val widget = findViewById<Widget>(R.id.roktWidget)
val placeHolders = hashMapOf(
Pair("RoktEmbedded1", WeakReference(widget))
)
Rokt.selectPlacements(
identifier = "RoktExperience",
attributes = attributes,
placeholders = placeHolders,
onEvent = { roktEvent ->
// Handle Rokt events
}
)
...
}
}
import com.rokt.roktsdk.Widget;
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("sandbox", "true");
attributes.put("firstname", "Jenny");
attributes.put("lastname", "Smith");
attributes.put("mobile", "(323) 867-5309");
attributes.put("postcode", "90210");
attributes.put("country", "US");
// Widget placeholder mapping the placeholder view with placement location configuration
Widget widget = findViewById(R.id.roktWidget);
Map<String, WeakReference<Widget>> placeHolders = new HashMap<>();
placeHolders.put("RoktEmbedded1", new WeakReference<>(widget));
Rokt.INSTANCE.selectPlacements("RoktExperience",
attributes,
placeHolders,
roktEvent -> {
// Handle Rokt events
});
...
}
}