Track events on your app

This article provides steps on how to use the Blueshift's SDK to track events on your app.

📘

Wait. Are you ready for this part?

In this article, we'll show you the methods that are available in the SDK and how you can use these methods to track events on your app. However, this cannot work until you already have the SDK in your project and you can use it in your app. If not, then we suggest that you do those things first and then come back here to track events in your app.

It's absolutely not complicated. We promise. And, like earlier, we'll wait. No pressure. :relaxed:

Our SDK, along with the API, provides features that you can use to track events on your app, such as:

  • User checks in on the app
  • Identify the user
  • User adds a product to the cart
  • User checks out the product
  • User buys a product

The SDK can:

You can also send a custom JSON to our platform.


Events that you can track on your iOS app using the methods in the SDK

The list above represents some of the events that occur on your app that the SDK can track. Use the methods described below to track such events.

Custom events

Use the trackEventForEventName method to track custom events with custom attributes in your app.

Here's how to use it without parameters:

BlueShift.sharedInstance().trackEvent(forEventName: "your_custom_event_name", canBatchThisEvent: false)
[[BlueShift sharedInstance] trackEventForEventName:@"your_custom_event_name" canBatchThisEvent:YES];

Here's how to use it with parameters:

let dictionary = ["name": "shahas", "profession":"paleontologist"]
BlueShift.sharedInstance().trackEvent(forEventName: "your_custom_event_name", andParameters: dictionary, canBatchThisEvent: false)
NSDictionary *params = @{
                            @"name":@"Ross Geller",
                            @"profession":@"paleontologist"
                        }
[[BlueShift sharedInstance] trackEventForEventName:@"your_custom_event_name" andParameters:params canBatchThisEvent:NO];

Identify a user

Use the identifyUser method to track if the end-user signed into your app. The primary identifier used to identify a user is device_id that is passed to the identifierForVendor (IDFV). The device_id is set during the SDK initialization, and it is automatically sent to us. In addition to sending the device_id, we recommend that you set the email and customer_id of the user if you can. This ensures that we can still attribute the events to — and generate recommendations for — the user if the user resets the device_id.

Here's how to use it:

//Identify user using email id
BlueShiftUserInfo.sharedInstance()?.email = "User Email ID"
BlueShiftUserInfo.sharedInstance()?.save()
BlueShift.sharedInstance().identifyUser(withEmail: "User Email ID", andDetails: nil, canBatchThisEvent: false)

//Identify user with customer id
BlueShiftUserInfo.sharedInstance()?.retailerCustomerID = "User Customer ID"
BlueShiftUserInfo.sharedInstance()?.save()
BlueShift.sharedInstance().identifyUser(withDetails:nil, canBatchThisEvent: false)

//Identify user with device id
 BlueShift.sharedInstance().identifyUser(withDetails:nil, canBatchThisEvent: false)

//Identify user with custom details
let details = ["name": "Ross Geller", "profession":"paleontologist", "phone_number":"+919999999999"]
BlueShift.sharedInstance().identifyUser(withDetails:details, canBatchThisEvent: false)
//Identify user using email id
[[BlueShiftUserInfo sharedInstance] setEmail:@"User Email ID"];
[[BlueShiftUserInfo sharedInstance] save];
[[BlueShift sharedInstance] identifyUserWithEmail:@"User Email ID" andDetails:nil canBatchThisEvent:NO];

//Identify user with customer id
[[BlueShiftUserInfo sharedInstance] setRetailerCustomerID: "User Customer ID"];
[[BlueShiftUserInfo sharedInstance] save];
[[BlueShift sharedInstance] identifyUserWithDetails:nil canBatchThisEvent:NO];

//Identify user with device id.
[[BlueShift sharedInstance] identifyUserWithDetails:nil canBatchThisEvent:NO];

//Identify user with custom details
NSDictionary *details = @{  @"name":@"Ross Geller",
                            @"profession":@"paleontologist", 
                            @"phone_number":@"+919999999999"}
[[BlueShift sharedInstance] identifyUserWithDetails:details canBatchThisEvent:NO];

Screen view

Use the trackScreenViewedForViewController method to send the page_load event that tracks the screen a user sees.

Here's how to use it:

//Track screen view
BlueShift.sharedInstance().trackScreenViewed(for: self, canBatchThisEvent: false)

//Track screen view with details
let details = ["launchDetails": "PushNotificationDeepLink"]
BlueShift.sharedInstance().trackScreenViewed(for: self, withParameters: details, canBatchThisEvent: false)
//Track screen view
[[BlueShift sharedInstance] trackScreenViewedForViewController:self canBatchThisEvent:NO];

//Track screen view with details
NSDictionary *details = @{  @"launchDetails":@"PushNotificationDeepLink" }
[[BlueShift sharedInstance] trackScreenViewedForViewController:self withParameters:parametersDictionary canBatchThisEvent:NO];

Product view

Use the trackProductViewedWithSKU method to track views of a particular product on your app. It can take common attributes like sku and category_id. In addition, you can use the NSDictionary data type for additional parameters that your app should pass to the SDK.

Here's how to use it:

BlueShift.sharedInstance().trackProductViewed(withSKU: "Product SKU", andCategoryID: CategoryID, canBatchThisEvent: false)
[[BlueShift sharedInstance] trackProductViewedWithSKU:@"Product SKU" andCategoryID:@"Category ID" canBatchThisEvent:NO];

If you want your app to send additional parameters, here's how to do it:

BlueShift.sharedInstance().trackProductViewed(withSKU: "Product SKU", andCategoryID:1234 , withParameter: paramsDictionary, canBatchThisEvent: false)
[[BlueShift sharedInstance] trackProductViewedWithSKU:@"Product SKU" andCategoryID:1234 withParameter:parametersDictionary canBatchThisEvent:NO];

Add to cart

Use the trackAddToCartWithSKU method to track the add_to_cart event. The app can call this event when either a user clicks the add_to_cart button, or when the add_to_cart API is called.

Here's how to use it:

BlueShift.sharedInstance().trackAddToCart(withSKU: "Product SKU", andQuantity: 5, canBatchThisEvent: false)
[[BlueShift sharedInstance] trackAddToCartWithSKU:@"Product SKU" andQuantity:5 canBatchThisEvent:NO];

If you want your app to send additional parameters, here's how to do it:

BlueShift.sharedInstance().trackAddToCart(withSKU: "Product SKU", andQuantity: 5, andParameters: paramsDictionary, canBatchThisEvent: false)
[[BlueShift sharedInstance] trackAddToCartWithSKU:@"Product SKU" andQuantity:5 andParameters:parametersDictionary canBatchThisEvent:NO];

Cart checkout

Use the trackCheckOutCartWithProducts method to track a check out of a cart. The first argument to the method is the array of products in the cart, and this model is included in the SDK. You can create an instance and set the values in it using your product instance.

Here's how to use it:

let product1 = BlueShiftProduct()
product1.sku = "PRM123"
product1.price = 50
product1.quantity = 2

let product2 = BlueShiftProduct()
product2.sku = "PRM123"
product2.price = 50
product2.quantity = 2

let product3 = BlueShiftProduct()
product3.sku = "PRM123"
product3.price = 50
product3.quantity = 2

let products = [product1, product2, product3]
BlueShift.sharedInstance().trackCheckOutCart(withProducts: products, andRevenue: revenue, andDiscount: discount, andCoupon: coupon, canBatchThisEvent: false)
BlueShiftProduct *product1 = [[BlueShiftProduct alloc] init];[product1 setSku:@"PROM001"];
[product1 setPrice:100];
[product1 setQuantity:1];

BlueShiftProduct *product2 = [[BlueShiftProduct alloc] init];
[product2 setSku:@"SERSGQ002"];
[product2 setPrice:10];
[product2 setQuantity:2];

BlueShiftProduct *product3 = [[BlueShiftProduct alloc] init];
[product3 setSku:@"FERW006"];
[product3 setPrice:105];
[product3 setQuantity:1];

products = @[product1, product2, product3];

[[BlueShift sharedInstance] trackCheckOutCartWithProducts:products andRevenue:revenue andDiscount:discount andCoupon:coupon canBatchThisEvent:NO];

If you want your app to send additional parameters, here's how to do it:

BlueShift.sharedInstance().trackCheckOutCart(withProducts: [Any]!, andRevenue: Float, andDiscount: Float, andCoupon: String!, andParameters: [AnyHashable : Any]!, canBatchThisEvent: Bool)

BlueShiftProduct *product1 = [[BlueShiftProduct alloc] init];
[product1 setSku:@"PROM001"];
[product1 setPrice:100];
[product1 setQuantity:1];

BlueShiftProduct *product2 = [[BlueShiftProduct alloc] init];
[product2 setSku:@"SERSGQ002"];
[product2 setPrice:10];
[product2 setQuantity:2];

BlueShiftProduct *product3 = [[BlueShiftProduct alloc] init];
[product3 setSku:@"FERW006"];
[product3 setPrice:105];
[product3 setQuantity:1];

products = @[product1, product2, product3];    

BlueShift.sharedInstance().trackCheckOutCart(withProducts: products, andRevenue: revenue, andDiscount: discount, andCoupon: coupon, andParameters: paramsDictionary, canBatchThisEvent: false)
BlueShiftProduct *product1 = [[BlueShiftProduct alloc] init];
[product1 setSku:@"PROM001"];
[product1 setPrice:100];
[product1 setQuantity:1];

BlueShiftProduct *product2 = [[BlueShiftProduct alloc] init];
[product2 setSku:@"SERSGQ002"];
[product2 setPrice:10];
[product2 setQuantity:2];

BlueShiftProduct *product3 = [[BlueShiftProduct alloc] init];
[product3 setSku:@"FERW006"];
[product3 setPrice:105];
[product3 setQuantity:1];

products = @[product1, product2, product3];

[[BlueShift sharedInstance] trackCheckOutCartWithProducts:products andRevenue:revenue andDiscount:discount andCoupon:coupon andParameters:parametersDictionary canBatchThisEvent:NO];

Purchase

Use the trackProductsPurchased method to track a user's purchase of the products on your app.

Here's how to use it:

BlueShiftProduct *product1 = [[BlueShiftProduct alloc] init];
[product1 setSku:@"PROM001"];
[product1 setPrice:100];
[product1 setQuantity:1];

BlueShiftProduct *product2 = [[BlueShiftProduct alloc] init];
[product2 setSku:@"SERSGQ002"];
[product2 setPrice:10];
[product2 setQuantity:2];

BlueShiftProduct *product3 = [[BlueShiftProduct alloc] init];
[product3 setSku:@"FERW006"];
[product3 setPrice:105];
[product3 setQuantity:1];

products = @[product1, product2, product3];  

BlueShift.sharedInstance().trackProductsPurchased(products, withOrderID: orderID, andRevenue: revenue, andShippingCost: shippingCost, andDiscount: discount, andCoupon: coupon, canBatchThisEvent: false)
BlueShiftProduct *product1 = [[BlueShiftProduct alloc] init];
[product1 setSku:@"PROM001"];
[product1 setPrice:100];
[product1 setQuantity:1];

BlueShiftProduct *product2 = [[BlueShiftProduct alloc] init];
[product2 setSku:@"SERSGQ002"];
[product2 setPrice:10];
[product2 setQuantity:2];

BlueShiftProduct *product3 = [[BlueShiftProduct alloc] init];
[product3 setSku:@"FERW006"];
[product3 setPrice:105];
[product3 setQuantity:1];

products = @[product1, product2, product3];

[[BlueShift sharedInstance] trackProductsPurchased:products withOrderID:orderID andRevenue:revenue andShippingCost:shippingCost andDiscount:discount andCoupon:coupon canBatchThisEvent:NO];

If you want your app to pass additional parameters, here's how to do it:

BlueShift.sharedInstance().trackProductsPurchased([Any]!, withOrderID: String!, andRevenue: Float, andShippingCost: Float, andDiscount: Float, andCoupon: String!, andParameters: [AnyHashable : Any]!, canBatchThisEvent: Bool)

BlueShiftProduct *product1 = [[BlueShiftProduct alloc] init];
[product1 setSku:@"PROM001"];
[product1 setPrice:100];
[product1 setQuantity:1];

BlueShiftProduct *product2 = [[BlueShiftProduct alloc] init];
[product2 setSku:@"SERSGQ002"];
[product2 setPrice:10];
[product2 setQuantity:2];

BlueShiftProduct *product3 = [[BlueShiftProduct alloc] init];
[product3 setSku:@"FERW006"];
[product3 setPrice:105];
[product3 setQuantity:1];

products = @[product1, product2, product3]; 

BlueShift.sharedInstance().trackProductsPurchased(products, withOrderID: orderID, andRevenue: revenue, andShippingCost: shippingCost, andDiscount: discount, andCoupon: coupon, andParameters: paramsDictionary, canBatchThisEvent: false)
BlueShiftProduct *product1 = [[BlueShiftProduct alloc] init];
[product1 setSku:@"PROM001"];
[product1 setPrice:100];
[product1 setQuantity:1];

BlueShiftProduct *product2 = [[BlueShiftProduct alloc] init];
[product2 setSku:@"SERSGQ002"];
[product2 setPrice:10];
[product2 setQuantity:2];

BlueShiftProduct *product3 = [[BlueShiftProduct alloc] init];
[product3 setSku:@"FERW006"];
[product3 setPrice:105];
[product3 setQuantity:1];

products = @[product1, product2, product3];

[[BlueShift sharedInstance] trackProductsPurchased:products withOrderID:orderID andRevenue:revenue andShippingCost:shippingCost andDiscount:discount andCoupon:coupon andParameters:parameters canBatchThisEvent:NO];

Cancelled purchase

Use the trackPurchaseCancelForOrderID to track a purchase cancelled after an order is completed.
Here's how to use it:

BlueShift.sharedInstance().trackPurchaseCancel(forOrderID: orderID, canBatchThisEvent: false)
[[BlueShift sharedInstance] trackPurchaseCancelForOrderID:orderID canBatchThisEvent:NO];

If you want your app to pass additional parameters, here's how to do it:

BlueShift.sharedInstance().trackPurchaseCancel(forOrderID: orderID, andParameters: paramsDictionary, canBatchThisEvent: false)
[[BlueShift sharedInstance] trackPurchaseCancelForOrderID:orderID andParameters:parameters canBatchThisEvent:NO];

Return a purchase

Use the trackPurchaseReturnForOrderID method to track a return of a purchase. You can call this method when the purchase return API is called.

Here's how to use it:

BlueShiftProduct *product1 = [[BlueShiftProduct alloc] init];
[product1 setSku:@"PROM001"];
[product1 setPrice:100];
[product1 setQuantity:1];

BlueShiftProduct *product2 = [[BlueShiftProduct alloc] init];
[product2 setSku:@"SERSGQ002"];
[product2 setPrice:10];
[product2 setQuantity:2];

BlueShiftProduct *product3 = [[BlueShiftProduct alloc] init];
[product3 setSku:@"FERW006"];
[product3 setPrice:105];
[product3 setQuantity:1];

products = @[product1, product2, product3];
BlueShift.sharedInstance().trackPurchaseReturn(forOrderID: orderID, andProducts: dictionary, canBatchThisEvent: false)
BlueShiftProduct *product1 = [[BlueShiftProduct alloc] init];
[product1 setSku:@"PROM001"];
[product1 setPrice:100];
[product1 setQuantity:1];

BlueShiftProduct *product2 = [[BlueShiftProduct alloc] init];
[product2 setSku:@"SERSGQ002"];
[product2 setPrice:10];
[product2 setQuantity:2];

BlueShiftProduct *product3 = [[BlueShiftProduct alloc] init];
[product3 setSku:@"FERW006"];
[product3 setPrice:105];
[product3 setQuantity:1];

products = @[product1, product2, product3];

[[BlueShift sharedInstance] trackPurchaseReturnForOrderID:orderID andProducts:products canBatchThisEvent:NO];

If you want your app to pass additional parameters, here's how to do:

BlueShiftProduct *product1 = [[BlueShiftProduct alloc] init];
[product1 setSku:@"PROM001"];
[product1 setPrice:100];
[product1 setQuantity:1];

BlueShiftProduct *product2 = [[BlueShiftProduct alloc] init];
[product2 setSku:@"SERSGQ002"];
[product2 setPrice:10];
[product2 setQuantity:2];

BlueShiftProduct *product3 = [[BlueShiftProduct alloc] init];
[product3 setSku:@"FERW006"];
[product3 setPrice:105];
[product3 setQuantity:1];

products = @[product1, product2, product3];

BlueShift.sharedInstance().trackPurchaseReturn(forOrderID: orderID, andProducts: products, andParameters: paramsDictionary, canBatchThisEvent: false)
BlueShiftProduct *product1 = [[BlueShiftProduct alloc] init];
[product1 setSku:@"PROM001"];
[product1 setPrice:100];
[product1 setQuantity:1];

BlueShiftProduct *product2 = [[BlueShiftProduct alloc] init];
[product2 setSku:@"SERSGQ002"];
[product2 setPrice:10];
[product2 setQuantity:2];

BlueShiftProduct *product3 = [[BlueShiftProduct alloc] init];
[product3 setSku:@"FERW006"];
[product3 setPrice:105];
[product3 setQuantity:1];

products = @[product1, product2, product3];

[[BlueShift sharedInstance] trackPurchaseReturnForOrderID:orderID andProducts:products andParameters:parameters canBatchThisEvent:NO];

Product search

Use the trackProductSearchWithSkuArray method to track the events when a user searches for a product in your app. You can implement this method with optional filters and extra arguments.

Here's how to use it without optional filters and extra arguments:

BlueShift.sharedInstance().trackProductSearch(withSkuArray: [Any]!, andNumberOfResults: Int, andPageNumber: Int, andQuery: String!, andParameters: [AnyHashable : Any]!, canBatchThisEvent: Bool)
- (void)trackProductSearchWithSkuArray:(NSArray *)skuArray andNumberOfResults:(NSInteger)numberOfResults andPageNumber:(NSInteger)pageNumber andQuery:(NSString *)query andParameters:(NSDictionary *)parameters canBatchThisEvent:(BOOL)isBatchEvent;

Here's how to use it with optional filters:

BlueShift.sharedInstance().trackProductSearch(withSkuArray: [Any]!, andNumberOfResults: Int, andPageNumber: Int, andQuery: String!, andFilters: [AnyHashable : Any]!, canBatchThisEvent: Bool)
- (void)trackProductSearchWithSkuArray:(NSArray *)skuArray andNumberOfResults:(NSInteger)numberOfResults andPageNumber:(NSInteger)pageNumber andQuery:(NSString *)query andFilters:(NSDictionary *)filters canBatchThisEvent:(BOOL)isBatchEvent;

Here's how to use it with extra arguments:

BlueShift.sharedInstance().trackProductSearch(withSkuArray: [Any]!, andNumberOfResults: Int, andPageNumber: Int, andQuery: String!, andFilters: [AnyHashable : Any]!, andParameters: [AnyHashable : Any]!, canBatchThisEvent: Bool)
- (void)trackProductSearchWithSkuArray:(NSArray *)skuArray andNumberOfResults:(NSInteger)numberOfResults andPageNumber:(NSInteger)pageNumber andQuery:(NSString *)query andFilters:(NSDictionary *)filters andParameters:(NSDictionary *)parameters canBatchThisEvent:(BOOL)isBatchEvent;

Subscribe to emails

Use the trackEmailListSubscriptionForEmail method to track if the user has subscribed to emails.

Here's how to use it:

BlueShift.sharedInstance().trackEmailListSubscription(forEmail: "Email Id", canBatchThisEvent: false)
[[BlueShift sharedInstance] trackEmailListSubscriptionForEmail:@"Email Id" canBatchThisEvent:NO];

Here's how to use it with optional additional parameters:

BlueShift.sharedInstance().trackEmailListSubscription(forEmail: 
"Email Id", andParameters: paramsDictionary, canBatchThisEvent: false)
[[BlueShift sharedInstance] trackEmailListSubscriptionForEmail:@"Email Id" andParameters:paramsDictionary canBatchThisEvent:NO]

Unsubscribe from emails

Use the trackEmailListUnsubscriptionForEmail if a user unsubscribes from emails.
Here's how to use it:

BlueShift.sharedInstance().trackEmailListUnsubscription(forEmail: "Email Id", canBatchThisEvent: false)
[[BlueShift sharedInstance] trackEmailListUnsubscriptionForEmail:@"Email Id" canBatchThisEvent:NO]

Here's how to use it with optional additional parameters:

BlueShift.sharedInstance().trackEmailListUnsubscription(forEmail: "Email Id", andParameters: paramsDictionary, canBatchThisEvent: NO)
[[BlueShift sharedInstance] trackEmailListUnsubscriptionForEmail:@"Email Id" andParameters:paramsDictionary canBatchThisEvent:NO]

Initialize a subscription

Use the trackSubscriptionInitializationForSubscriptionState method to track if a user starts a subscription in your app.

Here's how to use it:

BlueShift.sharedInstance().trackSubscriptionInitialization(for: BlueShiftSubscriptionState, andCycleType: String!, andCycleLength: Int, andSubscriptionType: String!, andPrice: Float, andStartDate: TimeInterval, canBatchThisEvent: Bool)
- (void)trackSubscriptionInitializationForSubscriptionState:(BlueShiftSubscriptionState)subscriptionState andCycleType:(NSString *)cycleType andCycleLength:(NSInteger)cycleLength andSubscriptionType:(NSString *)subscriptionType andPrice:(float)price andStartDate:(NSTimeInterval)startDate canBatchThisEvent:(BOOL)isBatchEvent;

Here's how to use it with optional additional parameters:

BlueShift.sharedInstance().trackSubscriptionInitialization(for: BlueShiftSubscriptionState, andCycleType: String!, andCycleLength: Int, andSubscriptionType: String!, andPrice: Float, andStartDate: TimeInterval, andParameters: [AnyHashable : Any]!, canBatchThisEvent: Bool)
- (void)trackSubscriptionInitializationForSubscriptionState:(BlueShiftSubscriptionState)subscriptionState andCycleType:(NSString *)cycleType andCycleLength:(NSInteger)cycleLength andSubscriptionType:(NSString *)subscriptionType andPrice:(float)price andStartDate:(NSTimeInterval)startDate andParameters:(NSDictionary *)parameters canBatchThisEvent:(BOOL)isBatchEvent;

Pause a subscription

Use the trackSubscriptionPause method to track if a user has paused a subscription.
Here's how to use it:

BlueShift.sharedInstance().trackSubscriptionPause(withBatchThisEvent: Bool)
- (void)trackSubscriptionPauseWithBatchThisEvent:(BOOL)isBatchEvent;

Here's how to use it optional additional parameters:

BlueShift.sharedInstance().trackSubscriptionPause(withParameters: [AnyHashable : Any]!, canBatchThisEvent: Bool)
- (void)trackSubscriptionPauseWithParameters:(NSDictionary *)parameters canBatchThisEvent:(BOOL)isBatchEvent;

Resume/un-pause a subscription

Use the trackSubscriptionUnpause method to track if a user resumes a paused subscription.

Here's how to use it:

BlueShift.sharedInstance().trackSubscriptionUnpause(withBatchThisEvent: Bool)
- (void)trackSubscriptionUnpauseWithBatchThisEvent:(BOOL)isBatchEvent;

Here's how to use it with optional additional parameters:

BlueShift.sharedInstance().trackSubscriptionUnpause(withParameters: [AnyHashable : Any]!, canBatchThisEvent: Bool)
- (void)trackSubscriptionUnpauseWithParameters:(NSDictionary *)parameters canBatchThisEvent:(BOOL)isBatchEvent;

Cancel a subscription

Use the trackSubscriptionCancel method to track if a user cancels a currently running subscription.

Here's how to use it:

BlueShift.sharedInstance().trackSubscriptionCancel(withBatchThisEvent: Bool)
- (void)trackSubscriptionCancelWithBatchThisEvent:(BOOL)isBatchEvent;

Here's how to use it with optional additional parameters:

BlueShift.sharedInstance().trackSubscriptionCancel(withParamters: [AnyHashable : Any]!, canBatchThisEvent: Bool)
- (void)trackSubscriptionCancelWithParamters:(NSDictionary *)parameters canBatchThisEvent:(BOOL)isBatchEvent;

Events that the SDK tracks out-of-the-box

In addition, the SDK tracks App Open and Notification events natively. These methods are available in BlueShiftAppDelegate, so there's no need for your application to call any method.

App open

The SDK calls the app_open event every time when your customer taps on a push notification to launch the app or your customer launches the app from the closed state. The automatic App Open events on the app launch is basically a delayed event and it waits for the push notification device token to be available. If you are testing on the simulator or you have not set up the SDK for push notifications, then you will not be able to see the automatic app open events.
In case you want to fire app open explicitly from the app, here is how you can call it.

//You can pass the app open details as dictionary or pass it as nil
BlueShift.sharedInstance()?.appDelegate.trackAppOpen(withParameters: details)
//You can pass the app open details as dictionary or pass it as nil
[[[BlueShift sharedInstance]appDelegate] trackAppOpenWithParameters:details];

From SDK v2.1.13, the automatic app_open events when the app is launched from the killed state will be throttled by the SDK based on the automaticAppOpenTimeInterval. The default automaticAppOpenTimeInterval is set to 24 hours, so SDK will fire only one app_open event in 24 hours. This default behavior can be changed by setting the custom automaticAppOpenTimeInterval during SDK initialization.

// set time interval in seconds
config.automaticAppOpenTimeInterval = 60
// set time interval in seconds
[config setAutomaticAppOpenTimeInterval:60];

You can disable the automatic app_open events when the app is launched from the killed state by setting enableAppOpenTrackEvent to false during the SDK initialization.

config.enableAppOpenTrackEvent = false
[config setEnableAppOpenTrackEvent:false];

Notifications

These events enable accurate tracking and statistics around push notifications. If the application uses different frameworks or methods to render push notifications, implement the methods below to ensure accurate tracking of push notifications.

Notification view
This method is called when a push message is received and a notification is displayed to the user.

- (void)trackPushViewedWithParameters:(NSDictionary *)userInfo canBacthThisEvent:(BOOL)isBatchEvent;

📘

Note

The SDK cannot track all notifications since iOS mostly handles them. Typically, the above SDK method is triggered if a notification is pushed when the app is running in the foreground.

To increase notification delivery accuracy, you can include a notification service extension target in your app. However, to do this, you need a few things such as:

  • iOS 10 or later
  • Notification service extension included in your app that is integrated with our SDK, and the SDK method called inside it
  • The notification payload that contains the mutable content flag set as '1' to invoke the extension

Notification click
This method is called when a user taps on the notification or on the action button on the notification.

BlueShift.sharedInstance()?.trackPushClicked(withParameters: [AnyHashable : Any]!, canBatchThisEvent: Bool)
- (void)trackPushClickedWithParameters:(NSDictionary *)userInfo canBatchThisEvent:(BOOL)isBatchEvent;

What’s Next

As we discussed that to accurately track notifications -- for users with devices that have iOS 10 or later -- you can use the notification extensions to better integrate our platform with your app. For more information on how to do this, see:

Did this page help you?