Sample rate

How to do data sampling with SpeedCurve RUM.

Unlike some RUM tools, SpeedCurve allows you to control how many pageviews are sampled. This allows you to monitor your pages while staying within a reasonable budget. Sampling is done based on sessions, so your data includes full user journeys through your site.

There are two ways to set your sample rate: in your Settings and with the RUM API.

Use the sample rate in Settings

In your Settings, click on Edit RUM to change your sample rate. You can enter any integer (no decimals) from 0 to 100 inclusive.

This approach to setting the sample rate is easy for making changes since no code changes are necessary. However, the changes do not take effect immediately. When decreasing the sample rate, it can take as long as 15 minutes for the changes to propagate across the SpeedCurve servers. When increasing the sample rate, the change depends on whether the real user has lux.js in their browser cache. It can take up to a week for all copies of lux.js to be purged from real user's caches, but typically it takes 1-2 days.

Using the RUM API

The other way to set your sample rate is using LUX.samplerate from the RUM JS API. This approach is more work as it requires a change to your site's JavaScript. However, once you push the change it takes effect immediately. Just like in your Settings, this should be an integer between 0 and 100. For example:

LUX.samplerate = 40;

Make sure this is set before the main lux.js script is loaded.

Setting the sample rate in your code gives you a lot of flexibility because you can vary the sample rate on every page. Here are some scenarios where this is useful:

  • If you have multiple properties or products (e.g., marketing pages, customer pages, and support docs) you can vary LUX.samplerate depending on the type of page. You might want to have a higher sample rate for customer pages where the content varies depending on the specific user, and have a lower sample rate on the marketing and support pages where the content is more static.

  • If your product is used across multiple countries, you might want to have a higher sample rate for countries that have less traffic so that you have enough data to get statistically sound results.

  • If you're running an A/B test on a small subset (e.g., 0.1%) of users, you might want to collect 100% of that traffic in order to compare the different test cases.

❗️

Important note on sampling with the API

If you have a sample rate of less than 100% in your Settings, this will always take precedence over the LUX.samplerate value. For this reason, if you choose to set your sample rate using LUX.samplerate then you need to ensure the sample rate in your Settings is set to 100%.

How RUM sampling works

RUM sampling works at two layers: on the client and during beacon collection. This flow chart explains the points at which a beacon may be rejected.

How to determine your sample rate

Setting your sample rate starts with knowing the number of monthly page views for your site. For example, suppose your site gets ~100 million page views per month. If you buy a RUM plan that gives you up to 10 million page views per month, you would set the sample rate to 10%. (In fact, you might want to set it to 8% to allow some wiggle room for any spikes you might experience during the month and growth over the year.) 

As you use the RUM dashboards, if you find that you're drilling down to where the number of page views is too low (e.g., less than 1000 per data point), then you might want to increase your quota by adding an additional bundle of 10M page views. Then with a quota of 20 million page views, you could set the sample rate to 20% (or 18% to be safe).

See our pricing page for more information.

How to see and manage page views usage

Go to Admin -> Usage to see how many page views per billing month you are using.

Learn more on usage history and managing quota.