Anonymous tracking
This feature is available since v4.
Anonymous tracking is a tracker feature that enables anonymising various user and session identifiers to support user privacy in case consent for tracking the identifiers is not given.
On mobile, the following user and session identifiers can be anonymised:
- Client-side user identifiers:
- Client-side session identifiers:
sessionId
andpreviousSessionId
in Session entity. - Server-side user identifiers:
network_userid
anduser_ipaddress
event properties.
There are several levels to the anonymisation depending on which of the three categories are affected:
1. Full client-side anonymisation
In this case, we want to anonymise both the client-side user identifiers as well as the client-side session identifiers. This means disabling the Session context altogether and enabling user anonymisation:
- iOS
- Android (Kotlin)
- Android (Java)
let config = TrackerConfiguration()
.sessionContext(false) // Session context entity won't be added to events
.userAnonymisation(true) // User identifiers in Platform context (IDFA and IDFV) will be anonymised
val config = TrackerConfiguration("appId")
.sessionContext(false) // Session context entity won't be added to events
.userAnonymisation(true) // User identifiers in Platform context (IDFA and IDFV) will be anonymised
TrackerConfiguration config = new TrackerConfiguration("appId")
.sessionContext(false) // Session context entity won't be added to events
.userAnonymisation(true); // User identifiers in Platform context (IDFA and IDFV) will be anonymised
2. Client-side anonymisation with session tracking
This setting disables client-side user identifiers are but tracks session information. In practice, this means that events track the Session context entity but the userId
property is a null UUID (00000000-0000-0000-0000-000000000000
). In case Platform context is enabled, the IDFA identifiers will not be present.
- iOS
- Android (Kotlin)
- Android (Java)
let config = TrackerConfiguration()
.sessionContext(true) // Session context is tracked with the session ID
.userAnonymisation(true) // User identifiers in Session and Platform context are anonymised
val config: TrackerConfiguration = TrackerConfiguration("appId")
.sessionContext(true) // Session context is tracked with the session ID
.userAnonymisation(true) // User identifiers in Session and Platform context are anonymised
TrackerConfiguration config = new TrackerConfiguration("appId")
.sessionContext(true) // Session context is tracked with the session ID
.userAnonymisation(true); // User identifiers in Session and Platform context are anonymised
When anonymous tracking is enabled or disabled using tracker.setUserAnonymisation(true | false)
, the tracker starts a new session which results in a new sessionId
.
3. Server-side anonymisation
Server-side anonymisation affects user identifiers set server-side. In particular, these are the network_userid
property set in server-side cookie and the user IP address. You can anonymise the properties using the serverAnonymisation
flag in EmitterConfiguration
:
- iOS
- Android (Kotlin)
- Android (Java)
let config = EmitterConfiguration()
.serverAnonymisation(true)
val config = EmitterConfiguration()
.serverAnonymisation(true)
EmitterConfiguration config = new EmitterConfiguration()
.serverAnonymisation(true);
Setting the flag will add a SP-Anonymous
HTTP header to requests sent to the Snowplow collector. The Snowplow pipeline will take care of anonymising the identifiers.