Session and Source Tracking
From SDK Version 5.2.2 we have started supporting Session and Source Tracking and this is enabled by default in the SDK. Refer to the following docs to get more info on:
NOTE:
- To view Session And Source information tracked in the dashboard, get the same enabled by contacting the MoEngage support team.
- To track source information accurately make use of the UTM parameters in your deep-links and push notification payloads. Refer to this doc for more information on setting Source Properties.
Capture Deep-link Source
AppDelegate Swizzling
Calling of
processURL:
method is not required if AppDelegate Swizzling is enabled for SDK. For more info on AppDelegate Swizzling refer to this link.
For capturing source information via deep-link call processURL:
method in all the AppDelegate callbacks which you receive when a link is opened, please refer to code block below:
//MARK:- Deeplinks Processing
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
MoEngage.sharedInstance().processURL(url)
//rest of the implementation
return true
}
func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool
{
if userActivity.activityType == NSUserActivityTypeBrowsingWeb ,
let incomingURL = userActivity.webpageURL{
MoEngage.sharedInstance().processURL(incomingURL)
}
//rest of the implementation
return true;
}
//MARK:- Methods Deprecated from iOS9
func application(_ application: UIApplication, handleOpen url: URL) -> Bool {
MoEngage.sharedInstance().processURL(url)
//rest of the implementation
return true
}
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
MoEngage.sharedInstance().processURL(url)
//rest of the implementation
return true
}
Non-Interactive Event
Events that should not affect the session duration calculation in anyways in MoEngage Analytics should be marked as a Non-Interactive event.
These events:
- Do not start a new session, even when the app is in the foreground
- Do not extend the session
- Do not have information on source and session
For example, events that are tracked when the app is in the background to refresh the app content, these are not initiated by users and hence can be marked as non-interactive. To mark an event as non-interactive use setNonInteractive()
method of MOProperties
while tracking the event as shown below:
//Set Attributes
let dict : NSMutableDictionary = ["NewsCategory":"Politics"]
let properties = MOProperties.init(attributes: dict)
properties.addDateAttribute(Date(), withName:"refreshTime")
//Set the Event as Non-Interactive
properties.setNonInteractive()
//Track event
MoEngage.sharedInstance().trackEvent("App Content Refreshed", with: properties)
//Set Attributes
NSMutableDictionary *eventDict = [NSMutableDictionary dictionary];
eventDict[@"NewsCategory"] = @"Politics";
MOProperties* properties = [[MOProperties alloc] initWithAttributes:eventDict];
[properties addDateAttribute:[NSDate date] withName:@"refreshTime"];
//Set the Event as Non-Interactive
[properties setNonInteractive];
//Track event
[[MoEngage sharedInstance] trackEvent:@"App Content Refreshed" withProperties:properties];
Updated over 5 years ago