Our iOS client library ships with analytics support out of the box, and by default,
there are no explicit preferences you need to set in order to enable reporting.
The integration is handled automatically unless you set
NO. If so, verify you followed the steps in Automatic Integration
for proper integration.
Analytics Events and Uploading
Our client library stores events in a local database and uploads them periodically in a background thread. We’ve taken great care to make sure 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.
Custom events let you track user activities and key conversions in your application, and tie them back to corresponding push messaging campaigns. Custom events requires 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.
let event = UACustomEvent(name: "event_name", value: 123.12) // Set custom event properties customEvent.setBoolProperty(true, forKey: "boolean_property") customEvent.setStringProperty("string_value", forKey: "string_property") customEvent.setNumberProperty(11, forKey: "number_property") customEvent.setStringArrayProperty(["string_array_value_1", "string_array_value_2"], forKey: "string_array_property") // Record the event in analytics event.track()
UACustomEvent *event = [UACustomEvent eventWithName:@"event_name" value:@123.12]; // Set custom event properties [customEvent setBoolProperty:true forKey:@"boolean_property"]; [customEvent setStringProperty:@"string_value" forKey:@"string_property"]; [customEvent setNumberProperty:@11 forKey:@"number_property"]; [customEvent setStringArrayProperty:@[@"string_array_value_1", @"string_array_value_2"] // Record the event in analytics [event track]
Convenient templates are provided to create custom events for common account, media or retail related events. For more details see the Custom Event Templates topic guide.
In addition to Named Users, tags, and Tag Groups, you can assign up to 20 custom identifiers to users. Identifiers that define additional ways of looking at a user -- for example, iOS Vendor ID, iOS Advertising ID, Google Analytics CID, or any other identifier you deem significant -- can be added to your users.
// Get the current identifiers let identifiers = UAirship.shared().analytics.currentAssociatedDeviceIdentifiers() // Add any custom identifier identifiers.setIdentifier("customIdentifier", forKey:"customkey") // Optionally include advertising ID identifiers.advertisingID = ASIdentifierManager.sharedManager().advertisingIdentifier.UUIDString; identifiers.advertisingTrackingEnabled = ASIdentifierManager.sharedManager().advertisingTrackingEnabled; identifiers.vendorID = UIDevice.currentDevice().identifierForVendor?.UUIDString // Associate the identifiers UAirship.shared().analytics.associateDeviceIdentifiers(identifiers)
// Get the current identifiers UAAssociatedIdentifiers *identifiers = [[UAirship shared].analytics currentAssociatedDeviceIdentifiers]; // Add any custom identifier [identifiers setIdentifier:@"customIdentifier" forKey:@"customKey"]; // Optionally include advertising ID identifiers.advertisingID = [[ASIdentifierManager sharedManager].advertisingIdentifier] UUIDString]; identifiers.advertisingTrackingEnabled = [ASIdentifierManager sharedManager].advertisingTrackingEnabled; identifiers.vendorID = [[UIDevice currentDevice].identifierForVendor UUIDString]; // Associate the identifiers [[UAirship shared].analytics associateDeviceIdentifiers: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, even if Real-Time Data Streaming does not yet support the relevant integration. Unlike the other identifiers (e.g., tags), you cannot use custom identifiers to target your users.
The Airship SDK gives you the ability to track what screen a user views within the application, as well as how long the user stayed on that screen and the user's previous screen. These events then come through Airship Real-Time Data Streaming and allow you to see the path that a user takes through an application, or to trigger actions based on a user visiting a particular area of the application.
// Record the event [[UAirship shared].analytics trackScreen:@"MainScreen"];
When a new screen is tracked or when the application backgrounds, a screen tracking event will
be generated. Normally, screen tracking should be called in a view controllers
method, however it can be called anywhere in the application to start tracking a new screen event.
Features that depend on analytics being enabled may not work properly if it is disabled (reports, location segmentation, region triggers, push to local time).
If you do not wish to include analytics and reporting in your application, in your
AirshipConfig.plist file, simply set the
UAirship.shared().analytics.enabled = false
[UAirship shared].analytics.enabled = NO;
When analytics is disabled at runtime it will delete any locally stored events and prevent any events from uploading.