Analytics and Reporting

Learn how to use Airship analytics.

The Airship SDK stores batches of events and will upload them periodically in the background. We’ve taken great care to ensure that the database won’t grow beyond a small fixed size, so extended periods of lost connectivity are nothing to worry about. The event upload thread is woken up when new events are triggered and goes to sleep when there are no more events to process, so the impact on battery life is negligible.

For information about data collection and privacy, see: Data Collection.

Custom Events

Custom events let you track user activities and key conversions in your application, and tie them back to corresponding push messaging campaigns. Custom events require analytics to be enabled. If disabled, any event that is added to analytics will be ignored. For a more detailed explanation on custom events and possible use cases, see the Custom Events topic guide.

Recording custom events

CustomEvent.newBuilder("event_name")
    .setEventValue(123.12)
    .addProperty("my_custom_property", "some custom value")
    .addProperty("is_neat", true)
    .addProperty(
        "any_json", JsonMap.newBuilder()
            .put("foo", "bar")
            .build()
    )
    .build()
    .track()
CustomEvent.newBuilder("event_name")
        .setEventValue(123.12)
        .addProperty("my_custom_property", "some custom value")
        .addProperty("is_neat", true)
        .addProperty("any_json", JsonMap.newBuilder()
                .put("foo", "bar")
                .build())
        .build()
        .track();
let event = CustomEvent(name: "event_name", value: 123.12)
event.properties = [
    "my_custom_property": "some custom value",
    "is_neat": true,
    "any_json": [
        "foo": "bar"
    ]
]
event.track()
UACustomEvent *event = [UACustomEvent eventWithName:@"event_name" value:@123.12];
event.properties = @{
    @"my_custom_property": @"some custom value",
    @"is_neat": @YES,
    @"any_json": @{
        @"foo": @"bar"
    }
};
[event track];
var customEvent = new UACustomEvent("event_name", 123.12)
customEvent.addProperty("my_custom_property", "some custom value")
customEvent.addProperty("is_neat", true)
customEvent.addProperty("any_json", {
  "foo": "bar"
})
UrbanAirship.addCustomEvent(customEvent)
CustomEvent event = CustomEvent("event_name", 123.12);
event.setProperties({
  "my_custom_property": "some custom value",
  "is_neat": true,
  "any_json": {
    "foo": "bar"
  }
});
Airship.addCustomEvent(event);
var event = {
    "name": "event_name",
    "value": 123.12,
    "properties": {
      "my_custom_property": "some custom value",
      "is_neat": true,
      "any_json": {
        "foo": "bar"
      }
    }
}
UAirship.addCustomEvent(event)
CustomEvent customEvent = new CustomEvent();
customEvent.EventName = "event_name";
customEvent.EventValue = 123.45;
customEvent.AddProperty("my_custom_property", "some custom value");
customEvent.AddProperty("is_neat", true);
Airship.Instance.AddCustomEvent(customEvent);
var event = Airship.analytics.newEvent("event_name")
event.eventValue = 123.45
event.eventProperties = {
    is_neat: true,
    some_custom_: 124.49,
    my_custom_property: "some custom value",
    any_json: {
        foo: "bar"
    }
}
event.track()
CustomEvent customEvent = new CustomEvent();
customEvent.EventName = "event_name";
customEvent.EventValue = 123.45;
customEvent.AddProperty("my_custom_property", "some custom value");
customEvent.AddProperty("is_neat", true);
UAirship.Shared.AddCustomEvent(customEvent);

Custom Identifiers

Custom identifiers will be visible in Real-Time Data Streaming. We recommend adding any IDs that you may want to be visible in your event stream. You can assign up to 20 custom identifiers to a device. Unlike the other identifiers (e.g., tags), you cannot use custom identifiers to target your users.

Setting custom identifiers

UAirship.shared().analytics
    .editAssociatedIdentifiers()
    .addIdentifier("key", "value")
    .apply()
UAirship.shared().getAnalytics()
    .editAssociatedIdentifiers()
    .addIdentifier("key", "value")
    .apply();
let identifiers = Airship.analytics.currentAssociatedDeviceIdentifiers()
identifiers.set(identifier: "value", key:"key")
Airship.analytics.associateDeviceIdentifiers(identifiers)
UAAssociatedIdentifiers *identifiers = [UAirship.analytics currentAssociatedDeviceIdentifiers];
identifiers.setIdentifier("value", forKey:"key")
[UAirship.analytics associateDeviceIdentifiers:identifiers];
UrbanAirship.associateIdentifier("key", "value")
// Not supported
UAirship.setAssociatedIdentifier("key", "value")
Airship.Instance.AssociateIdentifier("key", "value");
Airship.analytics.editAssociatedIdentifiers()
  .setIdentifier("key", "value")
  .apply()
UAirship.Shared.AssociateIdentifier("key", "value");

Screen Tracking

The Airship SDK gives you the ability to track which screens a user views within the application, how long a user stayed on each screen, and also includes the user’s previous screen. These events then come through Airship Real-Time Data Streaming, allowing you to see the path that a user took through the application, or trigger actions based on a user visiting a particular area of the application.

Track a screen

UAirship.shared().analytics.trackScreen("MainScreen")
UAirship.shared().getAnalytics().trackScreen("MainScreen");
Airship.analytics.trackScreen("MainScreen")
[UAirship.analytics trackScreen:@"MainScreen"];
UrbanAirship.trackScreen("MainScreen")
UAirship.analytics().trackScreen("MainScreen")
UAirship.trackScreen("MainScreen")
Airship.Instance.TrackScreen("MainScreen")
Airship.analytics.trackScreen("MainScreen")
UAirship.Shared.TrackScreen("MainScreen")