Skip to main content
If your site sends a Content-Security-Policy header (or a <meta http-equiv> policy), the browser blocks the tracker unless the policy allows the gateway. Tested by the static example, whose server sends the policy below with every page; the browser matrix runs all its pages under it and checks that nothing is blocked.

What the tracker needs

Nothing else: the tracker needs no inline script, no eval, no style, no image, no frame and no worker. It uses WebCrypto in the page itself for the challenge.

The tested policy

The example builds its policy from the gateway origin:
With the example gateway that is the header
Add the two gateway entries to your own policy rather than replacing it with this one; the other directives are the example site’s own.

Notes

  • Self-hosted sdk.js (self-hosting.md): script-src then needs your own origin ('self') instead of the gateway, and connect-src still needs the gateway.
  • Nonces and 'strict-dynamic'. With a nonce-based policy, give the tag your nonce attribute; with 'strict-dynamic', host entries in script-src are ignored, so the nonce is required. These variants were not tested.
  • Page code that calls umami.track() must itself be allowed by the policy. The example keeps it in a file of its own (page.js) so that no inline script is needed.
  • Integrity is separate. The integrity attribute is checked whatever the policy says; a CSP does not replace it, and it does not replace a CSP.

What the browser tests check

The test page listens for securitypolicyviolation events, loads the home page with the policy above, sends a pageview and both kinds of custom event, and requires that no violation was reported and every event arrived, in Chromium, Firefox and WebKit (tests/e2e/specs/onboarding.spec.ts).