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:
- View events: Appearance of views (page views), which makes it possible to track which content is seen by users.
- Events: Custom events which can be used for measurement of application functionalities.
- Stream playback events: Audio and video consumption measurements for application using our SRG Media Player. Additional playback information (title, duration, etc.) must be supplied externally. For application using our SRG Data Provider library, though, this process is entirely automated.
- Integration with our SRG Identity library.
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:
- If you only need basic view and event tracking, just link against
SRGAnalytics
. If you need to track SwiftUI views link againstSRGAnalyticsSwiftUI
as well. - If you need SRG Media Player media playback tracking, also link against
SRGAnalyticsMediaPlayer
. - If you need SRG standard media playback tracking with associated media metadata retrieved by SRG Data Provider, also link against
SRGAnalyticsDataProvider
. This library provides several playback helpers you should use to ensure that context information is complete when playing a media. - If you are using SRG Identity in your project, also link against
SRGAnalyticsIdentity
.
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
forSRGAnalytics
events.ch.srgssr.analytics.mediaplayer
forSRGAnalyticsMediaPlayer
events.ch.srgssr.analytics.dataprovider
forSRGAnalyticsDataProvider
events.ch.srgssr.analytics.identity
forSRGAnalyticsIdentity
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.