MLAnalytics Class Reference

Inherits from NSObject
Declared in MLAnalytics.h

Overview

MLAnalytics provides methods to logging user behavior to analytics backend.

Events for Session starting and session ending are logged automatically when app enter foreground or background.

Other Methods

+ setSessionContinueSeconds:

Set the timeout for expiring a MaxLeap session.

+ (void)setSessionContinueSeconds:(int)seconds

Parameters

seconds

The time in seconds to set the session timeout to.

Discussion

This is an optional method that sets the time the app may be in the background before starting a new session upon resume. The default value for the session timeout is 0 seconds in the background.

Declared In

MLAnalytics.h

Custom Event Analytics

+ trackEvent:

Tracks the occurrence of a custom event and reports to MaxLeap backend.

+ (void)trackEvent:(NSString *)name

Parameters

name

The name of the custom event.

Declared In

MLAnalytics.h

+ trackEvent:count:

Tracks the occurrence of a custom event and reports to MaxLeap backend.

+ (void)trackEvent:(NSString *)name count:(int)count

Parameters

name

The name of the custom event.

count

The number of this event occurred.

Declared In

MLAnalytics.h

+ trackEvent:parameters:

Tracks the occurrence of a custom event with additional parameters.

+ (void)trackEvent:(NSString *)name parameters:(nullable NSDictionary ML_GENERIC ( NSString *, NSString *) *)parameters

Parameters

name

The name of the custom event.

parameters

The dictionary of additional information for this event.

Discussion

Event parameters can be used to provide additional information about the event. The parameters is a dictionary containing Key-Value pairs of parameters. Keys and values should be NSStrings.

The following is a sample to track a purchase with additional parameters:

@code NSDictionary *parameters = @{@“productName”: @“iPhone 6s”, @“productCategory”: @“electronics”}; [MLAnalytics trackEvent:@“productPurchased” parameters:parameters]; @endcode

Declared In

MLAnalytics.h

+ trackEvent:parameters:count:

Tracks the occurrence of a custom event with additional parameters.

+ (void)trackEvent:(NSString *)name parameters:(nullable NSDictionary ML_GENERIC ( NSString *, NSString *) *)parameters count:(int)count

Parameters

name

The name of the custom event.

parameters

The dictionary of additional information for this event.

count

The number of this event occurred.

Discussion

Event parameters can be used to provide additional information about the event. The parameters is a dictionary containing Key-Value pairs of parameters. Keys and values should be NSStrings.

The following is a sample to track a purchase with additional parameters:

@code NSDictionary *parameters = @{@“productName”: @“iPhone 6s”, @“productCategory”: @“electronics”}; [MLAnalytics trackEvent:@“productPurchased” parameters:parameters]; @endcode

Declared In

MLAnalytics.h

Page View Analytics

+ beginLogPageView:

Tracks the duration of view displayed.

+ (void)beginLogPageView:(NSString *)pageName

Parameters

pageName

The name of the page.

Discussion

Tracks the beginning of view display.

Declared In

MLAnalytics.h

+ endLogPageView:

Tracks the duration of view displayed.

+ (void)endLogPageView:(NSString *)pageName

Parameters

pageName

The name of the page.

Discussion

Tracks the ending of view display.

Declared In

MLAnalytics.h

IAP Purchase Analytics

+ onPurchaseRequest:isSubscription:

Tracks the beginning of requesting iap purchase.

+ (void)onPurchaseRequest:(SKPaymentTransaction *)transaction isSubscription:(BOOL)isSubscription

Parameters

transaction

The transaction

isSubscription

Whether the transaction is a subscription

Declared In

MLAnalytics.h

+ onPurchaseSuccess:isSubscription:

Tracks the success of iap purchase.

+ (void)onPurchaseSuccess:(SKPaymentTransaction *)transaction isSubscription:(BOOL)isSubscription

Parameters

transaction

The transaction

isSubscription

Whether the transaction is a subscription

Declared In

MLAnalytics.h

+ onPurchaseCancelled:isSubscription:

Tracks the occurrence of cancelling iap purchase.

+ (void)onPurchaseCancelled:(SKPaymentTransaction *)transaction isSubscription:(BOOL)isSubscription

Parameters

transaction

The transaction

isSubscription

Whether the transaction is a subscription

Declared In

MLAnalytics.h

+ onPurchaseFailed:isSubscription:

Tracks the failure of iap purchase.

+ (void)onPurchaseFailed:(SKPaymentTransaction *)transaction isSubscription:(BOOL)isSubscription

Parameters

transaction

The transaction

isSubscription

Whether the transaction is a subscription

Declared In

MLAnalytics.h