Skip to end of metadata
Go to start of metadata

The Medialets Analytics SDK allows you to record instances of virtually any event that occurs in your application using Custom Events. Whenever the desired event occurs in your application, the event instance is stored for transmission to the Medialets Muse™ server. Additionally, a dictionary of other data associated with your event can be included in what is sent. The Medialets Analytics SDK can also observe system notifications and record them as Notification Events. The gathered data is available in reports on Medialets Muse™ and can be downloaded in .cvs files for offline processing.

Custom Events

Add Custom Event capture to your application simply by calling the MedialetsAnalyticsManager's trackEvent: method.

Capturing Custom Event
[[MedialetsAnalyticsManager sharedInstance] trackEvent:@"Name of Event"];

By executing the code above, an event with the name provided (in our example, "Name of Event") will be automatically created in the local SQLite database for subsequent transmission to our servers. All event instances with the same name are aggregated and their statistics will be displayed in reports on the Medialets Muse™ website.

Attaching User Dictionaries to Custom Events

To capture even more information about your custom events you have the option of creating a dictionary containing your data and passing it to -trackEvent:withUserDict: or the new -trackEvent:withUserCount:userDuration:userDict: method as shown below.

NSDictionary *userDict = [NSDictionary dictionaryWithObjectsAndKeys:searchSring, @"searchVal", nil];
[[MedialetsAnalyticsManager sharedInstance] trackEvent:@"Search" withUserDict:userDict];

Dictionaries attached to custom events may contain only NSString and NSNumber objects. Each string may not be longer than 2,048 characters. If a user dictionary contains any other type of object it will be ignored.

Complex Events

To gather more detailed event data, create a Complex Event such as Timers, Counters and Collections.

Timers and Counters

If, for example, you wanted to track how many times and for how long a user interacted with a specific screen, you can easily record this using MedialetsEvent's startTimerForKey and endTimerForKey. Below is pseudocode that shows how this is accomplished:

//where appropriate, instantiate the event object
MedialetsEvent *screenEvent =  [[MedialetsEvent alloc] initWithKey:@"Screen 1 Event"];
.
.
// screen is displayed
[screenEvent startTimerForKey:@"DisplayDuration"];
[screenEvent incrementNumberForKey:@"DisplayCount"];
.
.
// screen is no longer displayed
[screenEvent endTimerForKey:@["DisplayDuration"];

Collections

If, for example, you are writing a game and are storing the user's score for each level of the game in a Dictionary, you can easily associate this type of information with an event. Below is pseudocode that shows how this is accomplished:

  NSDictionary *ammoDict = [NSDictionary dictionaryWithObjectsAndKeys:
  			  [NSNumber numberWithInt:10000], @"Bullets",
   			  [NSNumber numberWithInt:100], @"Missiles",
   			  [NSNumber numberWithInt:10], @"Nukes",
   			  nil];
 NSTimeInterval appStoreTime = 13.6;

 MedialetsEvent *myEvent = [[MMEvent alloc] initWithKey:@"AppStorePurchase"];
 [myEvent setString:@"Ammunition" forKey:@"Product"];
 [myEvent setString:@"Ammo01" forKey:@"SKU"];
 [myEvent setNumber:[NSNumber numberWithFloat:1.99] forKey:@"Price"];
 [myEvent addNumbersFromDictionary:ammoDict];
 [myEvent setDuration:appStoreTime forKey:@"AppStoreResponseTime"];
 [[MedialetsAnalyticsManager sharedInstance] trackEvent:myEvent];
 [myEvent release];

Observing and Recording Notifications

Notifications are a useful tool for sending events around your application without having to directly connect to (or even know about) all the objects that are interested in those events. The Medialets Mobile Analytics API makes it very easy to add the Analytics Manager to be an observer of your notifications.

If you are not familiar with notifications, we suggest reading the Notification Programming Topics Developer Guide included in Apple's iPhone OS documentation.
Observing and Recording Notifications
MyTwitterPoster *poster = [MyTwitterPoster sharedInstance];

// assume these are the names of the notifications sent by the poster object
NSArray *names = [NSArray arrayWithObjects:@"postSucceeded", @"postFailed", nil];
[[MedialetsAnalyticsManager sharedInstance] observeNotifications:names fromObject:poster];



Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.