Skip to end of metadata
Go to start of metadata

Declared in:
MedialetsEvent.h


Discussion:
Complex events can be tracked by creating an MedialetsEvent object instance. Create the instance, fill it with strings, numbers, and durations using the MedialetsEvent methods, then pass the event to the MedialetsAnalyticsManager shared instance.

For example:

MedialetsEvent *myEvent = [[MedialetsEvent alloc] initWithKey:@"AppStorePurchase"];
[myEvent setString:@"Ammunition" forKey:@"Product"];
[myEvent setString:@"Ammo01" forKey:@"SKU"];
[myEvent setNumber:[NSNumber numberWithFloat:1.99 forKey:@"Price"]];
[myEvent addNumbersFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys:
                      [NSNumber numberWithFloat:3.5], @"Health",
                      [NSNumber numberWithInt:10000], @"Bullets",
                      [NSNumber numberWithInt:100], @"Missiles",
                      [NSNumber numberWithInt:3], @"Nukes",
                       nil]];
[myEvent setDuration:self.appStoreTime forKey:@"AppStoreResponseTime"];
[[MedialetsAnalyticsManager sharedInstance] trackEvent:myEvent];
[myEvent release];

Preparation:
To make use of the MedialetsEvent class, you must import the MedialetsEvent.h file into your project.

In your project tree:

  • Select Other Sources
  • Right-click and select Add > Existing Files...
  • Choose the header file, MedialetsEvent.h, included in the Medialets Analytics SDK download.

Next, add the header #import statement for MedialetsEvent.h to any method where you'll be using the MedialetsEvent class:

#import "MedialetsEvent.h"

In this Section:


Method Summary

MedialetsEvent initWithKey:(NSString *)eventKey
          Returns an MedialetsEvent object initialized with the specified event key.
void setString:(NSString *)string forKey:(NSString *)key
          Adds a given key-value pair to the receiver, where the value is an NSString value.
void addStringsFromDictionary:(NSDictionary *)dictionary
          Adds to the receiver the entries from a dictionary.
void setNumber:(NSNumber *)number forKey:(NSString *)key
          Adds a given key-value pair to the receiver, where the value is an NSNumber value.
void addNumbersFromDictionary:(NSDictionary *)dictionary
          Adds to the receiver the entries from a dictionary.
void incrementNumberForKey:(NSString *)key
          Helper method to implement a simple counter. Adds one number to the number stored with the specified key and then re-saves it within the event.
void setDuration:(NSTimeInterval *)duration forKey:(NSString *)key
          Adds a given key-value pair to the receiver, where the value is an NSTimeInterval value.
void addDurationsFromDictionary:(NSDictionary *)dictionary
          Adds to the receiver the entries from a dictionary.
void startTimerForKey:(NSString *)key
          Starts a timer with the specified key.
NSTimeInterval endTimerForKey:(NSString *)key
          Ends timing for the specified key and saves the duration to the receiver with the key. Also returns the duration.


Method Detail

initWithKey:

- (id)initWithKey:(NSString *)eventKey

Returns an MedialetsEvent object initialized with the specified event key.

Returns:

An MedialetsEvent object initialized with the specified event key.


setString:forKey:

- (void)setString:(NSString *)string forKey:(NSString *)key

Adds a given key-value pair to the receiver, where the value is an NSString value.


addStringsFromDictionary:

- (void)addStringsFromDictionary:(NSDictionary *)dictionary

Adds to the receiver the entries from a dictionary.

Discussion:

Each value in the dictionary must be an NSString (or a subclass of NSString) object. Other object types will be discarded.


setNumber:

- (void)setNumber:(NSNumber *)number forKey:(NSString *)key

Adds a given key-value pair to the receiver, where the value is an NSNumber value.


addNumbersFromDictionary:

- (void)addNumbersFromDictionary:(NSDictionary *)dictionary

Adds to the receiver the entries from a dictionary.

Discussion:

Each value in the dictionary must be an NSNumber object. Other object types will be discarded.


incrementNumberForKey:

- (void)incrementNumberForKey:(NSString *)key

Helper method to implement a simple counter. Adds one number to the number stored with the specified key and then re-saves it within the event.


setDuration:forKey

- (void)setDuration:(NSTimeInterval *)duration forKey:(NSString *)key

Adds a given key-value pair to the receiver, where the value is an NSTimeInterval value.


addDurationFromDictionary:

- (void)addDurationsFromDictionary:(NSDictionary *)dictionary

Adds to the receiver the entries from a dictionary.

Discussion:

Each value in the dictionary must be an NSTimeInterval object. Other object types will be discarded.


startTimerForKey:

- (void)startTimerForKey:(NSString *)key

Starts a timer with the specified key.

Discussion:

Call -endTimerForKey: to get the elapsed time and save the duration to the event. Has no effect on the event unless matched with an -endTimerForKey: call.


endTimerForKey:

- (NSTimeInterval)endTimerForKey:(NSString *)key

Ends timing for the specified key and saves the duration to the receiver with the key. Also returns the duration.

Discussion:
Has no effect unless -startTimerForKey: was first called with a matching key.



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