Events
Events record what a contact does in your app. They appear on the contact's timeline and can start automations and build segments.
What it is
The SDKs send three kinds of events:
| Kind | Use for | In the panel |
|---|---|---|
| Custom event | Any action specific to your app | An event with your name and attributes |
| Screen event | A screen the contact opened | Screen activity, matched by screen name |
| Product event | A commerce action on a product (view, add to cart, purchase...) | A product event, plus product attributes |
How it works
Conditions
- The device needs a contact first. Events are recorded only after the first successful ping of an installation. See Contacts.
- Each event carries the time it was created. Events sent later from the offline queue keep that time. Exception: Flutter screen events carry no time, so they get the time the backend receives them.
Event names
- Use the same spelling and letter case every time.
Purchaseandpurchase(orSign upandsign_up) count as the same name, and the second spelling is rejected. - Keep names 255 characters or fewer, without HTML.
Event attributes
- Every new attribute name creates a new event attribute. Use a fixed set of names.
- The first value of an attribute sets its type for good. A later value of another type is dropped, while the event itself is still recorded.
- Do not send
nullvalues or empty attribute names. - Content that looks like an attack (for example SQL or path fragments typed by users) can be blocked by the firewall, and the event is lost.
Product events
- The product ID is required.
- The event type is one of a fixed list: add to cart, purchase, liking, add to observation, order, reservation, return, view, click, detail, add, remove, checkout, checkout option, refund, promo click.
- Extra parameters are stored as product attributes. A new value replaces the previous value of that attribute on the product.
- Two events with the same product, the same type and the same timestamp are recorded as one.
Screen events
Automations and segments match screen events by screen name only. Use stable, readable names.
Platform differences
| iOS | Android | Flutter | |
|---|---|---|---|
| Automatic screen tracking | No. Call trackScreen or use Trackable view controllers. | Optional, with trackAllActivities in the builder | Optional, with UserSdkNavigatorObserver for named routes |
| Event before the first ping | Not sent. The completion reports an error. | Sent without a contact key and rejected, then saved and sent again with the key on the next UserCom.getInstance() call | Sent and rejected |
| Result reported to your code | Completion handler with Bool and Error | No result for events | No result for events |