Skip to content

Content Security Policy

If your site sends a Content-Security-Policy header, allow the sources below so the snippet can load, apply changes and report data.

Required directives

Required directives
DirectiveAllowWhy
script-srchttps://app.splittesty.comLoads the runtime (spt.js) and, when widgets are used, spt-widgets.js.
script-srca nonce or hashThe install snippet is an inline script. Add a nonce to its <script> tag (recommended) or allow its hash.
connect-srchttps://edge.splittesty.comFetches campaign settings and sends events (fetch and sendBeacon).
style-src'unsafe-inline'The anti-flicker rule and custom CSS of variations are inserted as <style> elements.
script-src'unsafe-eval'Only if you use custom JavaScript in campaigns or “JavaScript condition” page rules: this code is executed with new Function.
img-srcyour image hostsOnly if variations add images hosted elsewhere: allow the hosts of those images.

Example policy

Merge these sources into your existing policy. Replace the nonce with the per-request value your server generates.

Content-Security-Policy:
  script-src 'self' 'nonce-{RANDOM}' https://app.splittesty.com;
  connect-src 'self' https://edge.splittesty.com;
  style-src 'self' 'unsafe-inline';
  img-src 'self' data: https:;

Only if you use custom JavaScript in campaigns or “JavaScript condition” page rules: this code is executed with new Function.

script-src 'self' 'nonce-{RANDOM}' 'unsafe-eval' https://app.splittesty.com;

Using a nonce

Add the nonce attribute to the install snippet. With strict-dynamic the runtime loaded by the snippet is trusted automatically; without it, keep the script host in script-src.

<!-- SplitTesty -->
<script nonce="{RANDOM}">(function(w,d,a,p,u,t,h){ /* install snippet from the dashboard */ })(window,document, … );</script>
<!-- /SplitTesty -->

What happens when something is blocked

  • Snippet or runtime blocked: no experiment runs and visitors see the original page.
  • Settings request blocked: the page is revealed after the settings timeout and no campaign runs.
  • Styles blocked: the anti-flicker rule and custom CSS have no effect; changes made in the visual editor still apply because they are set through the DOM.
  • Eval blocked: custom JavaScript is skipped; all other changes still apply.

Visual editor and frame restrictions

The visual editor loads your page inside the dashboard. If your site forbids framing with frame-ancestors or X-Frame-Options, either allow the dashboard origin in frame-ancestors, or use the browser extension, which lifts these headers only for your own tab while an editor session is open.

Content-Security-Policy: frame-ancestors 'self' https://app.splittesty.com;

Roll out safely

Test changes with Content-Security-Policy-Report-Only first and watch the browser console for violations. Open a page with ?spt_debug=1 to confirm that the snippet loaded its settings.

Security notes

Custom code in a campaign is your own code and runs only on your own sites. Only editors of your workspace can change it, every change is recorded in the campaign history, and preview links are signed and expire.