Batch allows you to track events that happen in your application. They automatically keep track of their count, the last time it happened and their value.

- Please read our guide on custom data before tagging your app.
- Newly tracked events are hidden by default. You will need to manually display them from the dashboard settings > "Custom data" tab.

Tracking events

Events are easy to use, but have some rules:

  • Event names are strings. They should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
  • They can have a label, which is a string with no limitations (optional).
  • A custom data object can be attached. It must be an instance of Windows.Data.Json.JsonObject. Though it will be collected by Batch, it cannot be used for targeting purposes at the moment (optional).

Here's an example:

using Windows.Data.Json;
using BatchSDK;

Batch.User.TrackEvent("tab_clicked", "activity");

JsonObject data = new JsonObject()
  {"utm_campaign", JsonValue.CreateStringValue("thanksgiving_promo")}
Batch.User.TrackEvent("ad_seen", null, data);

Tracking transactions

We also have a specialized kind of events: Transactions. They let you track a transaction of a certain amount, but also allow you to specify the currency.

They also have some rules:

  • Amount should be a double.
  • A custom data object is supported, just like standard events (optional).

Here's an example:


JsonObject data = new JsonObject()
  {"item", JsonValue.CreateStringValue("100gold")}
Batch.User.TrackTransaction(20.5, data);

Make sure you start Batch before or after tracking your events. Otherwise, they will not be sent!