Actions are the events that occur in your Android app that you want to measure. Each action has one or more corresponding metrics that are incremented each time the event occurs. For example, you might send a trackAction
call for each new subscription, each time an article is viewed, or each time a level is completed.
You must call trackAction
when an event that you want to track occurs. In addition to the action name, you can send additional context data with each track action call. This method sends an Analytics action tracking hit with optional context data.
+ (void) trackAction: (nullable NSString*) action data: (nullable NSDictionary*) data;
Here are examples in Objective-C and Swift:
Objective-C
[ACPCore trackAction:@"action name" data:@{@"key":@"value"}];
Swift
ACPCore.trackAction("action name", data: ["key": "value"])
States are the different screens or views in your application. Each time a new state is displayed in your application, for example, when a user navigates from the home page to the news feed, a trackState
call should be sent. The tracking state name is typically called from a UIViewController
in the viewDidLoad
method. This method sends an Analytics state tracking hit with optional context data.
Tip: Calling this API will increment page views.
+ (void) trackState: (nullable NSString*) state data: (nullable NSDictionary*) data;
Here are examples in Objective-C and Swift:
Objective-C
[ACPCore trackState:@"state name" data:@{@"key":@"value"}];
Swift
ACPCore.trackState("state name", data: ["key": "value"])
Clears all hits from the tracking queue and removes the hits from the database.
Warning: Use caution when clearing the queue manually because this process cannot be reversed.
+ (void) clearQueue;
Here are examples in Objective-C and Swift:
Objective-C
[ACPAnalytics clearQueue];
Swift
ACPAnalytics.clearQueue()
Forces the library to send all queued hits regardless of the current batch options.
Here are examples in Objective-C and Swift:
+ (void) getQueueSize: (nonnull void (^) (NSUInteger queueSize)) callback;
Here are examples in Objective-C and Swift:
Objective-C
[ACPAnalytics getQueueSize: ^(NSUInteger queueSize) {
// use queue size
}];
Swift
ACPAnalytics.getQueueSize({queueSize in
// use queue size
})
Retrieves the analytics tracking identifier.
+ (void) getTrackingIdentifier: (nonnull void (^) (NSString* __nullable trackingIdentifier)) callback;
Here are examples in Objective-C and Swift:
Objective-C
[ACPAnalytics getTrackingIdentifier:^(NSString * _Nullable trackingIdentifier) {
// use returned tracking id
NSLog(@"Tracking ID : %@", trackingIdentifier);
}];
Swift
ACPAnalytics.getTrackingIdentifier({trackingIdentifier in
// use returned tracking id
}
Regardless of how many hits are currently queued, this method forces the library to send all hits in the offline queue.
Warning: Use caution when manually clearing the queue. This process cannot be reversed.
+ (void) sendQueuedHits;
Here are examples in Objective-C and Swift:
Objective-C
[ACPAnalytics sendQueuedHits];
Swift
ACPAnalytics.sendQueuedHits()