Skip to main content

Custom Events

Custom events record any action specific to your app, with a name and attributes you choose. General rules for names, attributes and results: Sending Events.


Requirements​

  • A successful ping() in this installation, see Contacts.
  • A stable event name and a fixed set of attribute names, see Naming rules.

Setup​

Call sendEvent where the action happens:

UserCom.default?.sendEvent(
"subscription_started",
mapOf("plan" to "pro", "billing_cycle" to "annual", "price" to 99.99)
) { error ->
if (error != null) Log.w("App", "Event failed: ${error.message}")
}
Check

The event appears on the contact's timeline with its attributes. It can now be used in segments and automations.


Methods​

sendEvent​

Queues a custom event for the current contact.

Optional unless marked required

nameStringrequired
The event name. Use the same spelling and letter case every time.
attributesMap<String, Any>?
Event attributes, see Attribute value types. Default null.
callbackUserComCallback?
Called with the result on the main thread. See Callback thread.

Returns nothing. Without a contact (no successful ping yet), the callback gets NotIdentified and the event is not queued. An invalid name or attribute value ends with InvalidName or InvalidData without a request. See Errors.

UserCom.default?.sendEvent("onboarding_completed")

Common errors​

SymptomCauseFix
Callback reports NotIdentifiedNo successful ping yet.Call ping() first.
Some attributes are missing on the eventA value type differs from the first value sent for that attribute.Keep each attribute's type stable.
The event is missing, and after the retries the callback reports RejectedThe name was used before with different letter case.Use one exact spelling.