Skip to content

Commit 768bf25

Browse files
authored
Merge pull request #5957 from segmentio/sarahrudy-patch-6
Analytics.js: Add FAQ about CSPs
2 parents 05bd46d + 6262702 commit 768bf25

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/connections/sources/catalog/libraries/website/javascript/troubleshooting.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,22 @@ Regarding cookies set by [device-mode destinations](/docs/connections/destinatio
203203

204204
The Analytics.js library sets the `context.page.referrer` value from the `window.document.referrer` [property](https://developer.mozilla.org/en-US/docs/Web/API/Document/referrer){:target="_blank"} set in the browser. If you notice unexpected referrer values reaching Segment, check how this value is being set on your website.
205205

206+
## Does Segment support using strict Content Security Policy (CSP) on the page?
207+
208+
If you're using a security policy that allows JavaScript downloads from specific locations using nonces, then you'll need to update the CSP to include all Segment domains. In addition to allowing the main `analytics.min.js` script, you should also allow the following paths in your CSP:
209+
- `https://cdn.segment.com/v1/projects/<WRITE_KEY>/settings`
210+
- `https://cdn.segment.com/analytics-next/bundles/*`
211+
- `https://cdn.segment.com/next-integrations/integrations/*`
212+
213+
Your CSP may also require allowlisting approved domains, in which case you'll want to allow the following endpoints:
214+
- `api.segment.io`
215+
- `cdn.segment.com`
216+
217+
You'll also need to modify the Segment script with your `nonce` tag, which should match the value specified in your Content Security Policy.
218+
219+
> info ""
220+
> Since Segment interacts with several integrations, support surrounding Content Security Policy issues is limited.
221+
206222
## Known issues:
207223

208224
[Review and contribute to these on GitHub](https://github.com/segmentio/analytics.js/issues).

0 commit comments

Comments
 (0)