Tracking Custom Events Developers Guide
From Medialets Developer Documentation
Contents |
Overview
Medialets lets you custom-tailor its tracking to your application, allowing you to track any event you like. All you need to do is tell Medialets when the event happens by passing a key for the event. Medialets records the event under your key and it can even store a dictionary of any additional data associated your event. Additionally Medialets can observe notifications for you and record them as notification events. All of your custom data is available on the Medialytics site or as downloadable CSV files that you can process yourself.
Defining Keys
Event keys are just an arbitrary string you use to identify your events. Your tracking data is your own and you don't have to worry about picking names that nobody else will use. Additionally, as the event keys will be displayed in your analytics charts, you probably want to choose names that are meaningful and descriptive. Don't get carried away, as long names will not display well and also make your event tracking messages bigger. Simple keys like "Update Settings" and "Search By Name" and "Share By Email" work best.
Examples:
[[MMTrackingMgr sharedInstance] trackEvent:@"Find Friend By Name"]; [[MMTrackingMgr sharedInstance] trackEvent:@"Share By Email"]; [[MMTrackingMgr sharedInstance] trackEvent:@"Connection Failed"];
Sending Extra information in a User Dictionary
When tracking events, it is often useful to send along extra information to help you understand what the user is doing with your application. If you are tracking every time a user does a search, recording the string they searched for might help improve the search functionality. Just create an NSDictionary with the data you want to track with the event and supply it to the Tracking Manager's trackEvent:withUserDict: method.
Examples:
NSDictionary *userDict1 = [NSDictionary dictionaryWithObjectsAndKeys:searchSring, @"searchVal", nil]; [[MMTrackingMgr sharedInstance] trackEvent:@"Search" withUserDict:userDict1]; NSDictionary *userDict2 = [NSDictionary dictionaryWithObjectsAndKeys: serverURL, @"url", tries, @"connectionAttempts", nil]; [[MMTrackingMgr sharedInstance] trackEvent:@"Connect Failed" withUserDict:userDict2];
Observing Notifications
Notifications are very useful 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 Tracking API makes it very easy to add the Tracking Manager to the observers of your notifications.
If you are unfamiliar with notifications, we suggest you read the "Notification Programming Topics" developer guide in the iPhone OS documentation.
Example:
MyTwitterPoster *poster = [MyTwitterPoster sharedInstance]; // assume these are the names of the notifications sent by the poster object NSArray *names = [NSArray arrayWithObjects:@"postStarted", @"postSucceeded", @"postFailed", nil]; [[MMTrackingMgr sharedInstance] observeNotifications:names fromObject:poster];
Medialytics Guide Feedback
We're always looking to improve our documentation. If you have any thoughts on the Medialytics Guide, let us know at Talk:Mobile Tracking Library Introductory Guide.
