Session and Source Tracking 7.x.x

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:

warning

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. For more information about setting Source Properties, refer to this User Source.

Capture Deep-link Source

info

AppDelegate Swizzling

Calling of processURL: method is not required if AppDelegate Swizzling is enabled for SDK. For more info on AppDelegate Swizzling, refer to Push Notification Implementation.

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:

Swift
//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, 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:

Swift Objective-C
//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)

Previous

Next

Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?