Repository navigation
Track events
Each Event contains bundleId, bundleVersion, appName, deviceId, with the following default values:
| Key | iOS Default Value | Android Default Value |
|---|---|---|
| appId | Bundle Identifier | App Identifier |
| appVersion | CFBundleShortVersionString | PackageInfo versionName. |
| appName | CFBundleDisplayName (or CFBundleName) | App Name |
| deviceId | IDFA (or "${IDFV}-IDFV") | AAID (or "${SSAID}-SSAID") |
you have the option to override the default values for bundleId, bundleVersion, appName, and deviceId. By default, these are set as follows:
Note
It's important to override these values only once. After setting them, all subsequent events will utilize the provided information.
OmniSegment.setAppId('setAppId');
OmniSegment.setAppVersion('appVersion');
OmniSegment.setAppName('appName');
OmniSegment.setDeviceId('deviceId');Note
Manually setting these values will override the SDK's default configuration.
Important
In our system, deviceId is referred to as cid. Before a user logs in, cid is used to ensure that all events triggered by the user are recorded in our system. This is particularly useful for maintaining user event tracking continuity prior to authentication.
Warning
By default, this SDK use IDFA as cid on ios device for events. But if user disable tracking permission on the app, IDFA will be 000, and we will prevent to send the event if cid is 000. To avoid this, recommend to set your own cid by using setDeviceId
Will send a event to OmniSegment server.
OmniSegment.trackEvent(OSGEventBuilder.search('...'));You can use build-in events including custom event:
let buildInEvent = OSGEventBuilder.search('...');
let customEvent = OSGEventBuilder.custom('...', '...');| Event Name | Static function | Recommended Calling Time | Description |
|---|---|---|---|
| App Open | appOpen() | When the app is launched | Used for recording the FCM (Firebase Cloud Messaging) token upon app launch. This event is typically triggered every time the app is opened by the user. |
| App Unsubscribe | appUnsubscribe() | At user logout | Unsubscribes the user from push notifications. |
| Product Impression | productImpression(products: OSGProduct) |
||
| Product Click | productClicked(products: OSGProduct) |
||
| Add to Cart | addToCart(products: OSGProduct) |
||
| Remove from Cart | removeFromCart(products: OSGProduct) |
||
| Checkout | checkout(products: OSGProduct) |
||
| Purchase | purchase(transactionId: string, revenue: Number, products: OSGProduct) |
||
| Refund | refund(transactionId: string, revenue: Number, products: OSGProduct) |
||
| Complete Registration | completeRegistration({ email: "your email" }) email, regType is accepted
|
||
| Search | search({ search_string: "your search string"}) | ||
| Custom Event | custom(action: string, value: string) |
| Property Name | Type | Required | Description |
|---|---|---|---|
| userId | string | *Yes | User ID. Default is the uid you set before. |
| deviceId | string | Device ID. If not set, will use default value | |
| bundleId | string | Bundle ID. If not set, will use default value | |
| bundleVersion | string | Bundle Version. If not set, will use default value | |
| appName | string | App Name. If not set, will use default value | |
| source | string | Enum WEB or APP, default is App
|
|
| location | string | The page key where the event is triggered. If a page view event follows a tracking link event, the location parameter needs to be updated accordingly | |
| locationTitle | string | The page title where the event is triggered. | |
| products | OSGProduct | The products related to the event. | |
| currencyCode | string | The transaction currency code. | |
| transactionId | string | The transaction ID. | |
| transactionRevenue | Number | The transaction revenue. | |
| transactionTax | string | The transaction tax. | |
| transactionShipping | string | The transaction shipping. | |
| transactionCouponCode | string | The transaction coupon. | |
| label | string | Dictionary of event label. | |
| value | string | Event value. | |
| extraAttributes | { [key: string]: any } | Extra attributes. |
Besides, you can add custom attributes to the event:
let exampleEvent = OSGEventBuilder.search('...');
exampleEvent.extraAttributes = { key: 'value' };Note: Custom attributes will override the default attributes with the same key.
| Property Name | Type | Required | Description |
|---|---|---|---|
| id | string | *Yes | Product ID. |
| name | string | *Yes | Product Name. |
| price | Number | Product Price. | |
| category | string | Product Category. | |
| brand | string | Product Brand. Use "," to separate multiple product brands. | |
| quantity | string | Product Quantity. | |
| variant | string | Product specifications, color, size, packaging quantity, etc. | |
| sku | string | Product variant sku number. | |
| customAttributes | { [key: string]: any } | Custom attributes. |
Besides, you can add custom attributes to the event:
let exampleProduct = OSGProduct(id: "1", name: "product name");
exampleProduct.customAttributes = { key: 'value'};Note: Custom attributes will override the default attributes with the same key.