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 Events

// Tracks view cart event for a user.
Leanplum.track("View Cart");

// Tracks view cart event with numeric event parameter, itemsInCart.
Leanplum.track("View Cart", {itemsInCart: 4});

// Tracks an event with a value and two event parameters.
Leanplum.track("Purchase", 4.99, {itemCategory: 'Apparel', itemName: 'Shoes'});

You should track events only after calling Leanplum.start().

Monetization Event

To track monetization metrics, Leanplum treats your monetization event specially. By default, the event name is called "Purchase", and the value should be the revenue for the transaction in a common currency. You can change the event name from Analytics to a custom name. Simply go to the metric chooser by clicking the + tile, go to the Monetization category, and edit the purchase event. The changes will be applied retroactively.