Last active
August 29, 2015 14:01
-
-
Save randydailey/d7fd50e37cbe01d6e841 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // AppDelegate.m | |
| // | |
| // This skeleton code provides a custom 'tagEvent' wrapper method to be used in leiu of directly calling the Localytics | |
| // tagEvent method. This method will automatically detect when a customer lifetime value increase has occured and will | |
| // toggle a custom dimension after the first CLV increase has occured. | |
| @implementation AppDelegate | |
| - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
| { | |
| // Determine if it is the first run of the app, if so, then set default values for your dimensions | |
| if (isFirstRun) | |
| { | |
| // We are using custom dimension 0 to track whether a purchase event has happened | |
| [[LocalyticsSession shared] setCustomDimension:0 value:@"Not a purchaser"]; | |
| } | |
| return YES; | |
| } | |
| - (void)applicationDidBecomeActive:(UIApplication *)application | |
| { | |
| [[LocalyticsSession shared] LocalyticsSession:@"YOUR APP KEY GOES HERE"]; | |
| [[LocalyticsSession shared] resume]; | |
| [[LocalyticsSession shared] upload]; | |
| } | |
| - (void)applicationWillTerminate:(UIApplication *)application { | |
| [[LocalyticsSession shared] close]; | |
| [[LocalyticsSession shared] upload]; | |
| } | |
| - (void)applicationWillResignActive:(UIApplication *)application | |
| { | |
| [[LocalyticsSession shared] close]; | |
| [[LocalyticsSession shared] upload]; | |
| } | |
| -(void)exampleButtonPress | |
| { | |
| [AppDelegate tagEvent:@"Example Click" | |
| attributes:@{@"Button Color" : @"Blue"} | |
| customerValueIncrease:@5]; | |
| } | |
| + (void)tagEvent:(NSString *)name attributes:(NSDictionary *)attributes customerValueIncrease:(NSNumber *)customerValueIncrease | |
| { | |
| // If we detect a CLV increase, then toggle the custom dimension to indicate the customer is a purchaser | |
| if (customerValueIncrease > 0) | |
| { | |
| [[LocalyticsSession shared] setCustomDimension:0 value:@"Purchaser"]; | |
| } | |
| // Invoke the native Localytics tagEvent call to handle the actual tagging | |
| [[LocalyticsSession shared] tagEvent:name | |
| attributes:attributes | |
| reportAttributes:nil | |
| customerValueIncrease:customerValueIncrease]; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment