Setting a sample rate

If your site receives lots of traffic, you might want to distribute your “RUX credits” so you don’t run out of credits early in the month.

You can do this by defining a sample rate. The sample rate determines how often we should collect data. 

Choose a value between 0 and 1 (no more than two decimals). A sample rate of 0 will never collect data, and a sample rate of 1 will collect everything.

The default sample rate is 1.

If you only want to track every second page view, you set your sample rate to 0.5 (meaning 50%). If you wish to track every fourth page view, you set your sample rate to 0.25 (meaning 25%).

When you set a sample rate, metrics get calculated with a weighting.

Example of sample rate and its effect:

Total pageviews15.00010.00015.00012.5008.000
50% (0.5) sample rate7.5005.0007.5006.2504.000
25% (0.25) sample rate3.7502.5003.7503.1252.000
10% (0.1) sample rate1.5001.0001.5001.250800
1% (0.01) sample rate15010015012580

How to implement a sample rate

To get the sample rate to work, you need to modify your tracking script.

Insert this snippet of code into your current tracking script and change the value (after the equal sign and inside the quotes) to the sample rate you wish.


Example regular script:

<script async src="" data-alertdesk-token="INSERT-YOUR-ALERTDESK-RUX-TOKEN-HERE" data-alertdesk-sample-rate="0.5" type="text/javascript"></script>

For Google Tag Manager the setup is a bit different. See the example below:

Google Tag Manager Script:

<script type="text/javascript">
(function (d, t, r) {
    const s = d.createElement('script');
    s.setAttribute('src', '');
    s.async = true;
    s.setAttribute('data-alertdesk-token', t);
    s.setAttribute('data-alertdesk-sample-rate', r);
})(document, 'INSERT-TOKEN', '0.5');

You need to change the value inside the single quotes on the last line, where it says ‘0.5’.

Updated on June 9, 2021

Related Articles