PFAnalytics Class Reference

Inherits from NSObject
Declared in PFAnalytics.h

Overview

PFAnalytics provides an interface to Parse’s logging and analytics backend.

Methods will return immediately and cache the request (+ timestamp) to be handled “eventually.” That is, the request will be sent immediately if possible or the next time a network connection is available.

App-Open / Push Analytics

+ trackAppOpenedWithLaunchOptions:

Tracks this application being launched. If this happened as the result of the user opening a push notification, this method sends along information to correlate this open with that push.

+ (BFTask PF_GENERIC ( NSNumber *) *)trackAppOpenedWithLaunchOptions:(nullable NSDictionary *)launchOptions

Parameters

launchOptions

The NSDictionary indicating the reason the application was launched, if any. This value can be found as a parameter to various UIApplicationDelegate methods, and can be empty or nil.

Return Value

Returns the task encapsulating the work being done.

Discussion

Pass in nil to track a standard “application opened” event.

Declared In

PFAnalytics.h

+ trackAppOpenedWithLaunchOptionsInBackground:block:

Tracks this application being launched. If this happened as the result of the user opening a push notification, this method sends along information to correlate this open with that push.

+ (void)trackAppOpenedWithLaunchOptionsInBackground:(nullable NSDictionary *)launchOptions block:(nullable PFBooleanResultBlock)block

Parameters

launchOptions

The dictionary indicating the reason the application was launched, if any. This value can be found as a parameter to various UIApplicationDelegate methods, and can be empty or nil.

block

The block to execute on server response. It should have the following argument signature: ^(BOOL succeeded, NSError *error)

Discussion

Pass in nil to track a standard “application opened” event.

Declared In

PFAnalytics.h

+ trackAppOpenedWithRemoteNotificationPayload:

Tracks this application being launched. If this happened as the result of the user opening a push notification, this method sends along information to correlate this open with that push.

+ (BFTask PF_GENERIC ( NSNumber *) *)trackAppOpenedWithRemoteNotificationPayload:(nullable NSDictionary *)userInfo

Parameters

userInfo

The Remote Notification payload, if any. This value can be found either under UIApplicationLaunchOptionsRemoteNotificationKey on launchOptions, or as a parameter to application:didReceiveRemoteNotification:. This can be empty or nil.

Return Value

Returns the task encapsulating the work being done.

Declared In

PFAnalytics.h

+ trackAppOpenedWithRemoteNotificationPayloadInBackground:block:

Tracks this application being launched. If this happened as the result of the user opening a push notification, this method sends along information to correlate this open with that push.

+ (void)trackAppOpenedWithRemoteNotificationPayloadInBackground:(nullable NSDictionary *)userInfo block:(nullable PFBooleanResultBlock)block

Parameters

userInfo

The Remote Notification payload, if any. This value can be found either under UIApplicationLaunchOptionsRemoteNotificationKey on launchOptions, or as a parameter to application:didReceiveRemoteNotification:. This can be empty or nil.

block

The block to execute on server response. It should have the following argument signature: ^(BOOL succeeded, NSError *error)

Declared In

PFAnalytics.h

Custom Analytics

+ trackEvent:

Tracks the occurrence of a custom event.

+ (BFTask PF_GENERIC ( NSNumber *) *)trackEvent:(NSString *)name

Parameters

name

The name of the custom event to report to Parse as having happened.

Return Value

Returns the task encapsulating the work being done.

Discussion

Parse will store a data point at the time of invocation with the given event name.

Declared In

PFAnalytics.h

+ trackEventInBackground:block:

Tracks the occurrence of a custom event. Parse will store a data point at the time of invocation with the given event name. The event will be sent at some unspecified time in the future, even if Parse is currently inaccessible.

+ (void)trackEventInBackground:(NSString *)name block:(nullable PFBooleanResultBlock)block

Parameters

name

The name of the custom event to report to Parse as having happened.

block

The block to execute on server response. It should have the following argument signature: ^(BOOL succeeded, NSError *error)

Declared In

PFAnalytics.h

+ trackEvent:dimensions:

Tracks the occurrence of a custom event with additional dimensions. Parse will store a data point at the time of invocation with the given event name.

+ (BFTask PF_GENERIC ( NSNumber *) *)trackEvent:(NSString *)name dimensions:(nullable NSDictionary PF_GENERIC ( NSString *, NSString *) *)dimensions

Parameters

name

The name of the custom event to report to Parse as having happened.

dimensions

The NSDictionary of information by which to segment this event.

Return Value

Returns the task encapsulating the work being done.

Discussion

Dimensions will allow segmentation of the occurrences of this custom event. Keys and values should be NSStrings, and will throw otherwise.

To track a user signup along with additional metadata, consider the following:

NSDictionary *dimensions = @{ @“gender”: @“m”, @“source”: @“web”, @“dayType”: @“weekend” }; [PFAnalytics trackEvent:@“signup” dimensions:dimensions];

Warning: There is a default limit of 8 dimensions per event tracked.

Declared In

PFAnalytics.h

+ trackEventInBackground:dimensions:block:

Tracks the occurrence of a custom event with additional dimensions. Parse will store a data point at the time of invocation with the given event name. The event will be sent at some unspecified time in the future, even if Parse is currently inaccessible.

+ (void)trackEventInBackground:(NSString *)name dimensions:(nullable NSDictionary PF_GENERIC ( NSString *, NSString *) *)dimensions block:(nullable PFBooleanResultBlock)block

Parameters

name

The name of the custom event to report to Parse as having happened.

dimensions

The NSDictionary of information by which to segment this event.

block

The block to execute on server response. It should have the following argument signature: ^(BOOL succeeded, NSError *error)

Declared In

PFAnalytics.h