Don’t track Mixpanel events for debug ios builds

Developing a new app I didn’t want to pollute my analytics data in mixpanel with development / test data.  So I wanted a clean way to be able to separate the test data with the release data.  “Not” tracking anything when in development mode was an option but I kinda wanted to be testing this as well … making sure I was always tracking the right things.  At the same time, I also wanted to be able to blow away the metrics from development really easily.  You hit Mixpanels 500K free events surprisingly quickly.

So a drop dead simple way to do this was to create two different Mixpanel projects – one for release, and the other for debugging.

Then in your ios AppDelegate.m you can simply use the appropriate key based on what mode you’re in.

#ifdef DEBUG
@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    //Other stuff
    [Mixpanel sharedInstanceWithToken:MIXPANEL_TOKEN];
    return YES;

Now that I’ve done that, my development analytics data is nicely partitioned in one place (so I know things are working), and it’s easy to delete.