Repository navigation
Track events
ruofan edited this page Jan 23, 2024
·
8 revisions
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 can set these values by yourself:
OmniSegment.setAppId("AppId");
OmniSegment.setAppVersion("AppVersion");
OmniSegment.setAppName("AppName");
OmniSegment.setDeviceId("deviceId");Note: Setting these values will override the default values.
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 |
|---|---|
| App Open | appOpen() |
| App Unsubscribe | appUnsubscribe() |
| Product Impression | productImpression(List<OSGProduct> products) |
| Product Click | productClicked(List<OSGProduct> products) |
| Add to Cart | addToCart(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 | Description |
|---|---|---|
| userId | String | 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. |
| locationTitle | String | The page title where the event is triggered. |
| products | List | 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 | Description |
|---|---|---|
| id | String | Product ID. |
| name | String | 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"