PFAnalytics

Objective-C

@interface PFAnalytics : NSObject

Swift

class PFAnalytics : NSObject

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

  • 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.

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

    Declaration

    Objective-C

    + (id)trackAppOpenedWithLaunchOptions:(nullable NSDictionary *)launchOptions;

    Swift

    class func trackAppOpened(launchOptions: [AnyHashable : Any]? = nil) -> Any!

    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.

  • 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.

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

    Declaration

    Objective-C

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

    Swift

    class func trackAppOpenedWithLaunchOptions(inBackground launchOptions: [AnyHashable : Any]?, block: PFBooleanResultBlock? = nil)

    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)

  • 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.

    Declaration

    Objective-C

    + (id)trackAppOpenedWithRemoteNotificationPayload:
        (nullable NSDictionary *)userInfo;

    Swift

    class func trackAppOpened(withRemoteNotificationPayload userInfo: [AnyHashable : Any]?) -> Any!

    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.

  • 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.

    Declaration

    Objective-C

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

    Swift

    class func trackAppOpenedWithRemoteNotificationPayload(inBackground userInfo: [AnyHashable : Any]?, block: PFBooleanResultBlock? = nil)

    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)

Custom Analytics

  • Tracks the occurrence of a custom event.

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

    Declaration

    Objective-C

    + (id)trackEvent:(nonnull NSString *)name;

    Swift

    class func trackEvent(_ name: String) -> Any!

    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.

  • 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.

    Declaration

    Objective-C

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

    Swift

    class func trackEvent(inBackground name: String, block: PFBooleanResultBlock? = nil)

    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)

  • 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.

    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.

    Declaration

    Objective-C

    + (id)trackEvent:(nonnull NSString *)name
          dimensions:(nullable NSDictionary<NSString *, NSString *> *)dimensions;

    Swift

    class func trackEvent(_ name: String, dimensions: [String : String]?) -> Any!

    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.

  • 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.

    @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];

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

    Declaration

    Objective-C

    + (void)trackEventInBackground:(nonnull NSString *)name
                        dimensions:(nullable NSDictionary<NSString *, NSString *> *)
                                       dimensions
                             block:(nullable PFBooleanResultBlock)block;

    Swift

    class func trackEvent(inBackground name: String, dimensions: [String : String]?, block: PFBooleanResultBlock? = nil)

    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)