sampleRate
The sampleRate property controls client-side sampling for analytics events. Before an event is stored, the SDK may skip it so that only part of the traffic is sent. The default is 100, meaning no sampling.
Syntax
PiwikTracker.sharedInstance()?.sampleRate = sampleRate[PiwikTracker sharedInstance].sampleRate = sampleRate;Parameters
- sampleRate (integer, required)
A whole number from1to100(inclusive). RoughlysampleRate / 100of analytics events are kept. A value of100keeps all events. Default:100. The fraction is approximate because the SDK uses a discrete random draw.
Examples
To keep roughly 10% of analytics events, see Parameters for details about how the percentage is calculated:
PiwikTracker.sharedInstance()?.sampleRate = 10[PiwikTracker sharedInstance].sampleRate = 10;Notes
- Many
send...andtrack...methods returntrueeven when sampling drops the event. The return value indicates that no error occurred, not that the event was queued for sending. For a similar behavior, see optOut. - If sampling drops an event, the SDK doesn't store it.
Related methods
Updated 2 months ago
Did this page help you?