Request the following from support@netminers.net
- The latest Netminers tracking for API IOS.
- An Account id
- A breadcrumb version
The following example demonstrates the basic usage of the IOS API.
- (void)viewDidLoad
{
[super viewDidLoad];
...
// Initialize API
[NMTracker initAccountId: @"debug" withBreadCrumbVersion:@"1"];
// Send our first event, a PageView
[[NMTracker sharedTracker] postPageView:@"My App/Start" nameSpace:@"http://myiosapp.company.com"];
}
// Commerce action
- (void) buyproduct:(id)sender
{
NSString *namespace = @"http://myiosapp.company.com";
// Set product name
NSString *productName = @"Babelfish";
// Set product SKU/ID
NSString *productId = @"42";
// Set price
long unitPrice = 42;
// Set quantity
long quantity = 1;
// Set optional product properties
// Color: Yellow
// Category: Translator
// NOTE: initWithObjectsAndKeys uses reverse order: Value, Key, ..., Value, Key, nil
NSDictionary* properties = [[NSDictionary alloc] initWithObjectsAndKeys: @"Yellow", @"Color", @"Translator", @"Category", nil];
[[NMTracker sharedTracker] postCommerceAddProductName:productName productId:productId nameSpace:namespace unitPrice:unitPrice quantity:quantity properties:properties];
}
// A subpage event
- (void) tipAFriend:(id)sender
{
NSString *namespace = @"http://myiosapp.company.com";
// Set breadcrumb
NSString *breadCrumb = @"Tip a friend";
// Set optional properties for action
// Relationship: Colleague
// NOTE: initWithObjectsAndKeys uses reverse order: Value, Key, ..., Value, Key, nil
NSDictionary* properties = [[NSDictionary alloc] initWithObjectsAndKeys: @"Colleague", @"Relationship", nil];
[[NMTracker sharedTracker] postOther:breadCrumb nameSpace:namespace properties: properties];
}
Properties
Every tracking method have a variant/overload taking a NSDictionary called properties. For example:
(void) postPageView: (NSString *) breadCrumb nameSpace: (NSString *) nameSpace properties: (NSDictionary *) properties;
The NSDictionary can contain useful segmentation categories. For example:
- Gender: Male/Female
- Age: 0-25/26-30/31-45/etc.
- Color: Red/white/etc. etc.
Categories should always be chosen wisely, since queries in Netminers Insight may take a performance hit. Keep categories to a minimum and make them discreete and aim for low cardinality/member count. E.g. Track a login success action while adding additional information about the gender of a person who logged in.
NSDictionary* properties = [[NSDictionary alloc] initWithObjectsAndKeys: @"Colleague", @"Relationship", nil]; [[NMTracker sharedTracker] postOther:@"Tip a friend" nameSpace:@"http://myiosapp.company.com" properties: properties];
Initialization
- initAccountId: withBreadCrumbVersion:
Tracking methods
- postPageView: nameSpace:
- postPageView: nameSpace: properties:
- postCommerceAddProductName: productId: nameSpace: unitPrice: quantity:
- postCommerceAddProductName: productId: nameSpace: unitPrice: quantity: properties:
- postFieldChange: nameSpace: value:
- postFieldChange: nameSpace: value: properties:
- postOther: nameSpace:
- postOther: nameSpace: properties: