KiiAnalytics Class Reference
Inherits from | NSObject |
Declared in | KiiAnalytics.h |
Overview
The main SDK class
This class must be initialized on application launch using beginWithID:andKey:. This class also allows the application to make some high-level user calls and access some application-wide data at any time using static methods.
Class Methods
beginWithID:andKey:
Initialize the KiiAnalytics SDK
+ (void)beginWithID:(NSString *)appId andKey:(NSString *)appKey
Parameters
- appId
The application ID found in your Kii developer console
- appKey
The application key found in your Kii developer console
Discussion
Initialize the KiiAnalytics SDK
Should reside in applicationDidFinishLaunching:withResult:
Declared In
KiiAnalytics.h
beginWithID:andKey:andSite:
Initialize the KiiAnalytics SDK
+ (void)beginWithID:(NSString *)appId andKey:(NSString *)appKey andSite:(KiiAnalyticsSite)kiiSite
Parameters
- appId
The application ID found in your Kii developer console
- appKey
The application key found in your Kii developer console
- kiiSite
One of the enumerator constants kiiAnalyticsSiteUS (United States), kiiAnalyticsSiteJP (Japan), kiiAnalyticsSiteCN (China), kiiAnalyticsSiteSG (Singapore) based on your desired location.
Discussion
Initialize the KiiAnalytics SDK
Should reside in applicationDidFinishLaunching:withResult: If Kii has provided a custom URL, use this initializer to set it
Declared In
KiiAnalytics.h
getResultSynchronousWithID:andQuery:andError:
Get a result set of analytics based on a specific query.
+ (KAGroupedResult *)getResultSynchronousWithID:(NSString *)aggregationRuleID andQuery:(KAResultQuery *)query andError:(NSError **)error
Parameters
- aggregationRuleID
The aggregation rule to slice data by
- query
The query object to use for retrieving data
- error
An NSError object, set to nil, to test for errors
Return Value
A result object with the segmented data broken into manageable data structures. Usually KAGroupedSnapShots.
Discussion
Get a result set of analytics based on a specific query.
This method allows you to use analytics results within your application. This method is blocking. Here is a sample snippet that get analytics data and output it to console log.
If you want to know more information of this analytics data, please see the GroupedResult item in Flex analytics Guide
NSError *error = nil;
KAGroupedResult *results = [KiiAnalytics getResultSynchronousWithID:@"my-aggregation-rule" andQuery:myQuery andError:&error];
if (error != nil) {
// There is something wrong...
return;
}
NSLog(@"Got results: %@", results);
// Get snapshots array
NSArray *snapshotArray = results.snapshots;
for (KAGroupedSnapShot *snapshot in snapshotArray) {
// Get the label of the dimension/grouping key.
NSLog(@"Name : %@", snapshot.name);
// Get the date in which the data starts.
NSLog(@"PointStart : %f", snapshot.pointStart);
// Get interval between data points.
NSLog(@"PointInterval : %f", snapshot.pointInterval);
// Get the JSON Array that contains the data retrieved by the query.
for (NSNumber *data in snapshot.data) {
NSLog(@"Data : %@", data);
}
}
Declared In
KiiAnalytics.h
getResultWithID:andQuery:andBlock:
Get a result set of analytics based on a specific query.
+ (void)getResultWithID:(NSString *)aggregationRuleID andQuery:(KAResultQuery *)query andBlock:(KAResultBlock)block
Parameters
- aggregationRuleID
The aggregation rule to slice data by
- query
The query object to use for retrieving data
- block
The block to be called upon method completion. See example
Discussion
Get a result set of analytics based on a specific query.
This method allows you to use analytics results within your application. This method is non-blocking. Here is a sample snippet that get analytics data and output it to console log.
If you want to know more information of this analytics data, please see the GroupedResult item in Flex analytics Guide
[KiiAnalytics getResultWithID:@"my-aggregation-rule"
andQuery:myQuery
andBlock:^(KAGroupedResult *results, NSError *error) {
if (error != nil) {
// There is something wrong...
return;
}
NSLog(@"Got results: %@", results);
// Get snapshots array
NSArray *snapshotArray = results.snapshots;
for (KAGroupedSnapShot *snapshot in snapshotArray) {
// Get the label of the dimension/grouping key.
NSLog(@"Name : %@", snapshot.name);
// Get the date in which the data starts.
NSLog(@"PointStart : %f", snapshot.pointStart);
// Get interval between data points.
NSLog(@"PointInterval : %f", snapshot.pointInterval);
// Get the JSON Array that contains the data retrieved by the query.
for (NSNumber *data in snapshot.data) {
NSLog(@"Data : %@", data);
}
}
Declared In
KiiAnalytics.h
trackEvent:
Log a single event to be uploaded to KiiAnalytics
+ (BOOL)trackEvent:(NSString *)event
Parameters
- event
A string representing the event name for later tracking. This must not nil or empty, and length must be less than or equals 128bytes in UTF-8.
Return Value
TRUE if the event was added properly, FALSE otherwise
Discussion
Log a single event to be uploaded to KiiAnalytics
Use this method if you’d like to track an event by name only. If you’d like to track other attributes/dimensions, please use trackEvent:withExtras: Will return TRUE every time unless there was an error writing to the cache.
Declared In
KiiAnalytics.h
trackEvent:withExtras:
Log a single event to be uploaded to KiiAnalytics
+ (BOOL)trackEvent:(NSString *)event withExtras:(NSDictionary *)extras
Parameters
- event
A string representing the event name for later tracking. This must not nil or empty, and length must be less than or equals 128bytes in UTF-8.
- extras
A dictionary of JSON-encodable key/value pairs to be attached to the event
Return Value
TRUE if the event was added properly, FALSE otherwise
Discussion
Log a single event to be uploaded to KiiAnalytics
Use this method if you’d like to track an event by name and add extra information to the event. Will return TRUE every time unless there was an error writing to the cache OR if one of the extra key/value pairs was not JSON-encodable.
Declared In
KiiAnalytics.h