[!IMPORTANT] Letterbox will be sunset in August 2025, replaced by Pillarbox. SRG Analytics will be decommissioned as well, replaced by an equivalent Analytics package available from Pillarbox:
- New SRG SSR products must use Pillarbox Analytics only.
- Existing SRG SSR products using SRG Analytics must transition to Pillarbox Analytics before this date.
The SRG Analytics library makes it easy to add usage tracking information to your iOS and tvOS applications, following the SRG SSR standards.
Measurements are based on events emitted by the application and sent to Commanders Act (for internal analytics purposes) as well as Mediapulse (for official audience measurements, via comScore).
The SRG Analytics library supports three kinds of measurements:
The library is suitable for applications running on iOS 12, tvOS 12 and above. The project is meant to be compiled with the latest Xcode version.
If you want to contribute to the project, have a look at our contributing guide.
The library must be integrated using Swift Package Manager directly within Xcode. You can also declare the library as a dependency of another one directly in the associated Package.swift
manifest.
The library is made of serveral smaller libraries. Which ones your project must link against depends on your needs:
SRGAnalytics
. If you need to track SwiftUI views link against SRGAnalyticsSwiftUI
as well.SRGAnalyticsMediaPlayer
.SRGAnalyticsDataProvider
. This library provides several playback helpers you should use to ensure that context information is complete when playing a media.SRGAnalyticsIdentity
.The library automatically tracks which SRG SSR applications are installed on a user device, and sends this information. For this mechanism to work properly, though, your application must declare all official SRG SSR application URL schemes as being supported in its Info.plist
file.
This can be achieved as follows:
LSApplicationQueriesSchemesGenerator.swift
script found in the Scripts
folder. This script automatically generates an LSApplicationQueriesSchemesGenerator.plist
file in the folder you are running it from, containing an up-to-date list of SRG SSR application schemes.plist
file and either copy the LSApplicationQueriesSchemes
to your project Info.plist
file, or merge it with already existing entries.If URL schemes declared by your application do not match the current ones, application installations will not be accurately reported, and error messages will be logged when the application starts (see Logging below). This situation is not catastropic but should be fixed when possible to ensure better measurements.
The number of URL schemes an application declares is limited to 50. Please contact us if your application reaches this limit.
When you want to use classes or functions provided by one of the librares in your code, you must import it from your source files first. In Objective-C:
@import SRGAnalytics;
@import SRGAnalyticsMediaPlayer;
@import SRGAnalyticsDataProvider;
@import SRGAnalyticsIdentity;
or in Swift:
import SRGAnalytics
import SRGAnalyticsSwiftUI
import SRGAnalyticsMediaPlayer
import SRGAnalyticsDataProvider
import SRGAnalyticsIdentity
To learn about how the library can be used, have a look at the getting started guide.
The library internally uses the SRG Logger library for logging, with the following subsystems:
ch.srgssr.analytics
for SRGAnalytics
events.ch.srgssr.analytics.mediaplayer
for SRGAnalyticsMediaPlayer
events.ch.srgssr.analytics.dataprovider
for SRGAnalyticsDataProvider
events.ch.srgssr.analytics.identity
for SRGAnalyticsIdentity
events.This logger either automatically integrates with your own logger, or can be easily integrated with it. Refer to the SRG Logger documentation for more information.
You are required to provide additional information about the data collected by your app and how it is used. Please refer to our associated documentation for more information.
To test what the library is capable of, run the associated demo.
See the LICENSE file for more information.