Repository navigation
Track events
Each Event contains appId, appVersion, appName, deviceId, with the following default values:
| Key | Default Value |
|---|---|
| appId | App Identifier |
| appVersion | PackageInfo versionName. |
| appName | App Name |
| deviceId | 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("AppId");
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.
Will send a event to OmniSegment server.
OmniSegment.trackEvent(OSGEvent.search("..."));You can use build-in events including custom event:
OSGEvent buildInEvent = OSGEvent.search("...");
OSGEvent customEvent = OSGEvent.custom("action", "value");| 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(List<OSGProduct> products) |
||
| Product Click | productClicked(List<OSGProduct> products) |
||
| Add to Cart | addToCart(List<OSGProduct> products) |
||
| Add to Wishlist | addToWishlist(List<OSGProduct> products) |
||
| Remove from Cart | removeFromCart(List<OSGProduct> products) |
||
| Checkout | checkout(List<OSGProduct> products) |
||
| Purchase | purchase(String transactionId, Integer revenue, List<OSGProduct> products) |
||
| Refund | refund(String transactionId, Integer revenue, List<OSGProduct> products) |
||
| Complete Registration | completeRegistration(Map<String, Object> label) email, regType is accepted
|
||
| Search | search(Map<String, Object> label) search_string is accepted
|
||
| Custom Event | custom(String action, @Nullable String value) |
| 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 | List<OSGProduct> | The products related to the event. | |
| currencyCode | String | The transaction currency code. | |
| transactionId | String | The transaction ID. | |
| transactionRevenue | Integer | 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 |
Besides, you can add custom attributes to the event:
OSGEvent exampleEvent = OSGEvent.search("...");
exampleEvent.appendAttribute("key", value: "value");
// Or you can append multiple attributes at once
Map<String, Object> newAttributes = new HashMap<>();
newAttributes.put("key1", "value1");
newAttributes.put("key2", "value2");
exampleEvent.appendAttributes(newAttributes);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 | Integer | 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. | |
| position | Integer | Product position. |
Besides, you can add custom attributes to the event:
OSGProduct exampleProduct = new OSGProduct("id", "product name");
// Also you can append multiple attributes at once
Map<String, Object> newAttributes = new HashMap<>();
newAttributes.put("key1", "value1");
newAttributes.put("key2", "value2");
exampleEvent.appendAttributes(newAttributes);Note: Custom attributes will override the default attributes with the same key.
OSGProduct product = new OSGProduct("id", "product name")
product.price = 100
product.category = "category"
product.brand = "brand"
product.quantity = "1"
product.variant = "{\"color\": \"blue\"}"
product.sku = "sku"