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.

//appdelegate.m
#ifdef DEBUG
#define MIXPANEL_TOKEN @"YOUR_DEBUG_KEY"
#else
#define MIXPANEL_TOKEN @"YOUR_RELEASE_KEY"
#endif
@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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s