Swan SDK
E-commerce

Custom events

Track any other action in your app or site as your own event. It appears in Swan on its own, ready for segments and journeys.

Use a custom event for anything the standard e-commerce events don't cover, for example a banner tap, a quiz answer or a store-locator search.

There is nothing to set up. The first time Swan receives an event name, it is added to your events together with its fields, and you can use it in segments and journeys.

Use a standard event whenever one fits. If the action is on the Standard events page, call that method instead: segments, journeys and reports understand the standard events straight away.


Send a custom event

Pass an event name and the fields you want to keep with it.

Swan.track("bannerClicked", mapOf(
    "bannerId" to "summer-sale",
    "position" to 2,
    "personalised" to true,
    "tags" to listOf("sale", "summer"),
))

// An event with no fields
Swan.track("onboardingDismissed")
Swan.shared.track("bannerClicked", attributes: [
    "bannerId": "summer-sale",
    "position": 2,
    "personalised": true,
    "tags": ["sale", "summer"],
])

// An event with no fields
Swan.shared.track("onboardingDismissed")
sdk?.customEvent('bannerClicked', {
    bannerId: 'summer-sale',
    position: 2,
    personalised: true,
    tags: ['sale', 'summer'],
});

// An event with no fields
sdk?.customEvent('onboardingDismissed');
Swan.track('bannerClicked', {
    bannerId: 'summer-sale',
    position: 2,
    personalised: true,
    tags: ['sale', 'summer'],
});

// An event with no fields
Swan.track('onboardingDismissed');

Every custom event also carries the details listed under Sent automatically with every event: platform, device, session, the customer, country, currency and business unit. You don't pass those.


Naming your events

  • Describe what happened, in camelCase: bannerClicked, quizCompleted, storeLocatorSearched.
  • Keep names stable. A renamed event, or an event name spelled differently, is a new event in Swan.
  • Field names are case-sensitive. Use the same field name every time, for example always bannerId, never sometimes bannerID.

Field values

ValueExampleIn Swan
Text"summer-sale"Text
Number2, 149.50Number
True / falsetrueTrue / false
List of values["sale", "summer"]List
Date and time"2026-10-14T10:30:00Z"Text, in ISO 8601 format

Swan sets each field's type from the first value it receives, so always send the same kind of value for a field: a number as a number (2), not sometimes as text ("2"). Send amounts as numbers in the currency's main unit, for example 149.50.


Reference

On this page