-
Notifications
You must be signed in to change notification settings - Fork 0
Track events
Each Event contains bundleId, bundleVersion, appName, deviceId, with the following default values:
| Key | Default Value |
|---|---|
| bundleId | Bundle Identifier |
| bundleVersion | CFBundleShortVersionString |
| appName | CFBundleDisplayName (or CFBundleName) |
| deviceId | Generated from IDFA, with a fallback to a combination of IDFV and "-IDFV" if IDFA is unavailable. |
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.setBundleId("bundleId")
OmniSegment.setBundleVersion("bundleVersion")
OmniSegment.setAppName("appName")
OmniSegment.setDeviceId("deviceId")[OmniSegment setBundleId:@"test-BundleId"];
[OmniSegment setBundleVersion:@"test-BundleVersion"];
[OmniSegment setAppName:@"test-app"];
[OmniSegment setDeviceId:@"test-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.
NSDictionary *searchLabel = @{@"search_string": searchBar.text};
OSGEvent *event = [OSGEvent searchWithLabel:searchLabel];
event.location = @"app://sidebar";
event.locationTitle = @"sidebar";
[OmniSegment trackEvent:event];
OmniSegment.trackEvent(.search(label: "..."))You can use build-in events including custom event:
// ISO 8601
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"];
[dateFormatter setLocale:[NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"]];
[dateFormatter setTimeZone:[NSTimeZone localTimeZone]];
NSString *currentDate = [dateFormatter stringFromDate:[NSDate date]];
NSDictionary *eventData = @{
@"ClickDate": currentDate,
@"EmailEvent": @"renee.wei@bebit-tech.com",
@"CampaignName": @"bebit"
};
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:eventData
options:0
error:&error];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
OSGEvent *event = [OSGEvent customWithAction:@"EmailEvent" value:jsonString];
event.location = @"app://product-list";
event.locationTitle = @"product-list-page";
[OmniSegment trackEvent:event];
let buildInEvent = OSGEvent.search(label: "...")
let 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(_ products: OSGProduct) |
||
| Product Click | productClicked(_ products: OSGProduct) |
||
| Add to Cart | addToCart(_ products: OSGProduct) |
||
| Add to Wishlist | addToWishlist(_ products: OSGProduct) |
||
| Remove from Cart | removeFromCart(_ products: OSGProduct) |
||
| Checkout | checkout(_ products: OSGProduct) |
||
| Purchase | purchase(_ transactionId: String, revenue: Int, products: OSGProduct) |
||
| Refund | refund(_ transactionId: String, revenue: Int, products: OSGProduct) |
||
| Complete Registration | completeRegistration(label: [String: Any]) email, regType is accepted
|
||
| Search | search(label: [String: Any]) search_string is accepted
|
||
| 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 | Int | 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:
let exampleEvent = OSGEvent.search(label: "...")
exampleEvent.appendAttribute("key", value: "value")
exampleEvent.appendAttributes(["key1": "value1", "key2": "value2"])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 | Int | 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. |
Besides, you can add custom attributes to the event:
let exampleProduct = OSGProduct(id: "1", name: "product name")
exampleProduct.appendAttribute("key", value: "value")
exampleProduct.appendAttributes(["key1": "value1", "key2": "value2"])Note: Custom attributes will override the default attributes with the same key.
OSGProduct *osgProduct = [[OSGProduct alloc] initWithId:[NSString stringWithFormat:@"%@",
[self.contentDict valueForKey:@"ID"]]
name:[self.contentDict valueForKey:@"ProductName"]];
osgProduct.price = [[self.contentDict valueForKey:@"ProductPrice"] intValue];
osgProduct.brand = @"chiikawa";
osgProduct.sku = @"chiikawawa";
osgProduct.variant = @"{\"color\": \"white\"}";
OSGEvent *event = [OSGEvent productImpression:@[osgProduct]];let product = OSGProduct(id: "1", name: "product name")
product.price = 100
product.category = "category"
product.brand = "brand"
product.quantity = "1"
product.variant = "{\"color\": \"blue\"}"
product.sku = "sku"