Complete reference for the available event payload customization options.
5 minute read
This guide walks you through the event payload customization options available in the Kotlin SDK.
Overview
The Kotlin SDK provides a RudderOption instance that lets you customize the payload for any event type. You can use this instance to pass the following parameters:
Used to specify the integrations for which the event should be sent or blocked. You can also use it to specify some specific actions to be performed for a particular integration.
Passing specific configuration or data to a particular destination
integrations options
The integrations field accepts the following parameters:
Parameter
Data type
Description
All
Boolean
Global filtering status for all destinations. If set to false, RudderStack blocks the event from being sent to all destinations unless you override it with destination-specific parameters.
Default value:true
<Destination>
Boolean / Object
Specific destination to filter. It overrides the All parameter.
If the type is Object, then the SDK automatically assumes this parameter to be true. You can then use this field to send destination-specific configuration or data in cloud and device modes.
Default behavior
By default, the integrations object is configured to send the event to all destinations which are present and initialized.
{//.....
"integrations":{"All":true},//.....
}
You can override this behavior by tweaking the integrations object to allow or block specific destinations, or send any destination-specific information, as per your use case.
The externalId field of the RudderOption instance is used to set a custom user ID or specific IDs required by some integrations. RudderStack adds this value under the context.externalId field of the event payload.
The following snippet demonstrates how to add a custom externalId to your identify event before sending it to the Braze destination:
The customContext field of the RudderOption instance is used to add custom contextual information to the event payload. This field is a JSON object that can contain any key-value pairs.
The following snippet demonstrates how to add custom context to your track event:
Note that you cannot use the customContext field to override the default contextual fields set by the SDK. For example, if you set the device field in the customContext object, the SDK ignores it and uses the default device information instead. An example is shown below:
analytics.track(name="Track Event",properties=Properties(emptyMap()),options=RudderOption(customContext=buildJsonObject{put("Plan","Enterprise")// This will reflect in the final event payload
put("device",buildJsonObject{// This won't reflect in the final event payload
put("id","my-device-id")put("name","My Android Device")})}))
After making the above call, the context field of the event payload will contain the following:
{//.....
"context":{//.....
"Plan":"Enterprise","device":{// The default device info captured by the SDK
"id":"d190f76ea636bc44","manufacturer":"Google","model":"sdk_gphone64_arm64","name":"emu64a","type":"Android"},//.....
}//.....
}
Overriding default contextual fields
RudderStack does not recommend overriding the default contextual fields set by the SDK as it can lead to unexpected issues.
However, if you wish to do so, you can use a custom plugin to override the default contextual fields.
Example
The following snippet demonstrates how to use the RudderOption instance to customize the event payload:
analytics.identify(userId="1hKOmRA4GRlm",options=RudderOption(integrations=buildJsonObject{put("Firebase",false)// Event disabled for Firebase
},externalIds=listOf(ExternalId(type="brazeExternalId",id="Brz1hGXsD")),customContext=buildJsonObject{put("Plan","Enterprise")}))
String userId = “1hKOmRA4GRlm”;
Map<String, Object> context = new HashMap<>();
context.put(“Plan”, “Enterprise”);
ExternalId externalId = new ExternalId(“brazeExternalId”, “Brz1hGXsD”);
List externalIds = Arrays.asList(externalId);
Map<String, Object> integrations = new LinkedHashMap<>();
integrations.put(“Firebase”, false);
RudderOption option = new RudderOptionBuilder()
.setIntegrations(integrations)
.setExternalId(externalIds)
.setCustomContext(context)
.build();
analytics.identify(userId, option);
The above snippet:
Disables the identify event for the Firebase integration through the integrations parameter
Sets a custom user ID for the Braze integration through the externalId parameter
Adds custom contextual information (Plan: Enterprise) to the event payload through the customContext parameter
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.