LUX uses a cookie to track page views across a user's session. To prevent this cookie from being set before a user has given their consent, you can load LUX in two stages.

The LUX snippet contains two parts: the inline snippet, and the lux.js script.

Normally you would load LUX by putting both the inline snippet and the lux.js script into the <head> of your pages. To prevent LUX from setting a cookie straight away, you should put just the inline snippet into the <head> of your pages. This will allow LUX to collect CPU timing data, and will also allow you to use the LUX API like normal.

After the user has given their consent for you to use cookies, the lux.js script can be loaded dynamically. An example of how to do this is below (be sure to replace LUX_ID with your real LUX ID):

var s = document.createElement("script");
s.src = "https://cdn.speedcurve.com/js/lux.js?id=LUX_ID";
s.async = true;
document.body.appendChild(s);

This will cause the lux.js script to be loaded into the page. After this, LUX will set the session cookie and track performance as normal.

Did this answer your question?