Skip to main content

Platform and application data tracking

Platform and application data tracking features capture information about the device and the app.

They are enabled by default. But the setting can be changed through TrackerConfiguration like in the example below:

let trackerConfig = TrackerConfiguration()
.platformContext(true)
.applicationContext(true)

Application context

The application context entity contains two properties:

PropertyTypeDescriptionRequired in schema
versionStringVersion number of the application e.g 1.1.0Yes
buildStringBuild name of the application e.g s9f2k2d or 1.1.0 betaYes

Platform (mobile) context

The platform context entity contains the following properties:

PropertyTypeAndroidiOSDescriptionRequired in schema
osTypeStringType of the operating system (e.g., "ios", "tvos", "watchos", "osx", "android")Yes
osVersionStringVersion of the mobile operating systemYes
deviceManufacturerStringDevice vendorYes
deviceModelStringModel of the deviceYes
carrierStringCarrier of the SIM inserted in the deviceNo
networkTypeStringOne of: "mobile", "wifi", "offline"No
networkTechnologyStringRadio access technology that the device is usingNo
openIdfaStringDeprecated propertyNo
appleIdfaStringAdvertising identifier on iOSNo
appleIdfvStringUUID identifier for vendors on iOSNo
androidIdfaStringAdvertising identifier on AndroidNo
physicalMemoryIntegerTotal physical system memory in bytesNo
systemAvailableMemoryIntegerAvailable memory on the system in bytesNo
appAvailableMemoryIntegerAmount of memory in bytes available to the current appNo
batteryLevelIntegerRemaining battery level as an integer percentage of total battery capacityNo
batteryStateStringBattery state for the device. One of: "unplugged", "charging", "full"No
lowPowerModeBooleanA Boolean indicating whether Low Power Mode is enabledNo
availableStorageIntegerBytes of storage remainingNo
totalStorageIntegerTotal size of storage in bytesNo
isPortraitBooleanA Boolean indicating whether the device orientation is portrait (either upright or upside down)No
resolutionStringScreen resolution in pixels. Arrives in the form of WIDTHxHEIGHT (e.g., 1200x900). Doesn't change when device orientation changes. See note below.No
scaleNumberScale factor used to convert logical coordinates to device coordinates of the screen (uses UIScreen.scale on iOS and DisplayMetrics.density on Android)No
languageStringSystem language currently used on the device (ISO 639)No
appSetIdStringAndroid vendor ID scoped to the set of apps published under the same Google Play developer account (see https://developer.android.com/training/articles/app-set-id)No
appSetIdScopeString (either "app" or "developer")Scope of the appSetId. Can be scoped to the app or to a developer account on an app store (all apps from the same developer on the same device will have the same ID)No
Android screen resolution

The screen resolution for the platform entity is obtained from the Android context resources. The height value will likely be lower than that reported in the canonical dvce_screenheight event property, which is fetched from WindowManager, an older API that still includes the menu bar.

To standardize the screen resolution between event and entity properties, provide a SubjectConfiguration with useContextResourcesScreenResolution(true) flag at tracker initialization. This flag is false by default, and available from Android tracker v6.0.3 onwards. Read about configuring Subject properties here.

Choosing which properties to track

You can choose which properties should be added to the platform context entity. By default, all available properties are tracked in the entity. In case you don't want certain properties to be tracked, you can choose the ones to track using TrackerConfiguration.platformContextEntities:

let trackerConfig = TrackerConfiguration()
.platformContextProperties([.batteryLevel, .isPortrait, .language])

Overriding platform context properties

In case you want to override the values for certain properties of the platform context (or provide ones that are not tracked by default, such as the totalStorage on iOS), you can set the platformContextRetriever in TrackerConfiguration to provide these values.

let trackerConfig = TrackerConfiguration()
.platformContextRetriever(
PlatformContextRetriever(deviceVendor: { "my-custom-vendor" })
)

Identifier for Advertisers (IDFA/AAID)

The IDFA advertising identifiers are only added to the platform context if you fulfill the following requirements. Otherwise, their values will be NULL.

The Apple advertising identifier is stored in the appleIdfa property.

Starting with iOS 14, one has to request user consent through the App Tracking Transparency framework in order to access the advertising identifier.

  1. Add and follow the guidelines of App Tracking Transparency Framework in your app.
  2. Pass a callback to your TrackerConfiguration that retrieves the identifier:
import AdSupport

let tracker = Snowplow.createTracker(namespace: "ns", network: networkConfig) {
TrackerConfiguration()
.advertisingIdentifierRetriever {
ASIdentifierManager.shared().advertisingIdentifier
}
}
note

The simulators can’t generate a proper IDFA, instead they generate a sequence of zeros. If you want to test IDFA with a real code, please use the physical device.

The user has the ability to limit ad-tracking from the device’s Settings. If the user enable the limitations the tracker will not be able to track the IDFA.

App set ID (Android only)

To identify a set of apps owned by an organization, Google provides the app set ID. Read more about it here.

An extra dependency is required to populate the Android-specific properties appSetId and appSetIdScope within the platform context entity.

dependencies {
...
implementation 'com.google.android.gms:play-services-appset:16.0.2'
...
}