Custom Event (Version 3.x)

A custom event lets you track unique user interactions and send data that isn't covered by standard events. You can include a flexible payload of user-defined attributes to capture the specific details of an interaction. You can then map these attributes to a Custom Event Schema in Data 360 using the Mobile Schema naming conventions.

Custom Event Example for iOS

Here's an example of a custom event that captures a user's gift preferences.

Note: In this example, mobileAppEvent is a sample name parameter value. Set the name parameter to a value that matches the developerName defined in your Custom Event Schema in Data 360.

CustomEvent(
    name: "mobileAppEvent",
    attributes: [
        "giftWrap" : true,
        "giftMessage" : "Happy Birthday",
        "giftWrapOptions": [
            "paperColor": "green",
            "ribbon": false
  ]
    ]
)

To see how a schema maps, see Custom Event Schema.

Custom Event Example for Android

Here's an example showing the same custom event for capturing a user's gift preferences on Android.

EventManager.customEvent(
    name = "mobileAppEvent",
    attributes = mapOf(
        "gift" to mapOf(
            "message" to "Happy Birthday",
            "wrap" to true,
            "wrapOptions" to mapOf(
                "paper-color" to "green",
                "ribbon" to false
            )
        )
    )
)?.track()

Nested attribute keys are flattened using parent-child naming (for example, gift.message becomes giftMessage) per the schema mapping rules.