Leanplum automatically logs session and user information for you. If you want more detailed information, such as how much ad revenue you made, or how long your users played each level of your game, you can set that up with Events and States.

An event is anything that can occur in your app. Events include clicking on a link, sharing, purchasing, killing enemies, etc. All events are timestamped according to when they occur. Thus, it is not advisable to log too many (thousands) of events, as each one will have to be sent to our server.

A parameter is a piece of data associated with an event or state. You can supply parameters as a dictionary along with events and states. Here are some reports you can run with parameters:

  • Filter reports by event parameter values

  • Group metrics by distinct event parameter values (creates a bar graph + table).

    Example: Show me my top purchased items.

  • Group metrics by ranges of event parameter values (creates a histogram + table).

    Example: Show me the distribution of purchase prices.

    Example: Show me the distribution of points scored.

  • Create custom metrics for numeric parameter values, like totals and averages.

    Example: For a purchase event, track the average revenue and the amount of currency bought per user.

Parameters are not available in Developer activity analytics, but you can verify your parameters are being tracked correctly in the Debugger console.

Events and states accumulate over time, and we send events in batches periodically to minimize network usage and maximize battery life.

Tracking an Event

// User killed an enemy.
[Leanplum track:@"Kills"];

// User completed a challenge.
[Leanplum track:@"Score" withValue:challengeValue.intValue];
[Leanplum track:@"Challenges"];

// User liked a post.
[Leanplum track:@"Likes"];

// Or, you can supply a dictionary with up to 200 numerical or string parameters.
[Leanplum track:@"Likes" withParameters:@{@"post": @(}];
// User killed an enemy.

// User completed a challenge.
Leanplum.track("Score", withValue: 1)

// User liked a post.
Leanplum.track("Likes", withInfo:

// Or, you can supply a dictionary with up to 200 numerical or string parameters.
Leanplum.track("Likes", withParameters:["post"])

You should track events only after calling [Leanplum start].

Tracking Purchase or Monetization Events

You can track purchases or other monetization events in Leanplum, which will provide you with revenue metrics in your reports.

In-App Purchases

If your app uses in-app purchases, Leanplum can automatically track those purchases and validate receipts with the App Store. Simply include the following line before your call to [Leanplum start]:

[Leanplum trackInAppPurchases];

Leanplum will also convert all purchases to USD. To require valid receipts upon purchase or change your preferred currency, update your app settings.

Other Monetization Events

If you are not using in-app purchases, you can manually track your monetization event. It works like any other event, except you use "Purchase" as the event name. For your convenience, you can also use the constant LP_PURCHASE_EVENT which is "Purchase". For example:

[Leanplum track:LP_PURCHASE_EVENT withValue:19.99];
Leanplum.track(LP_PURCHASE_EVENT, withValue:19.99)

The value should be the revenue for the transaction in a common currency.

If you prefer to use a different event name than "Purchase", you can select a new name. Simply go to the metric chooser by clicking the + tile on the Analytics page, go to the Monetization category, and edit the purchase event. The changes will be applied retroactively.