# איך להוסיף סקריפטי אנליטיקס ופיקסל מבלי להפר את מדיניות האבטחה של תוכן (XSS)

**URL:** https://meta.discourse.org/t/how-to-add-analytics-and-pixel-scripts-avoiding-content-security-policy-xss/321022
**Category:** Data & reporting
**Tags:** analytics
**Created:** [10 באוגוסט,‏ 2024,‏ 11:31am UTC](https://meta.discourse.org/t/how-to-add-analytics-and-pixel-scripts-avoiding-content-security-policy-xss/321022 "2024-08-10T11:31:56Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![jericson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jericson/32/116215_2.png) [@jericson](https://meta.discourse.org/u/jericson)
#### Post date: [7 בספטמבר,‏ 2024,‏ 11:42pm UTC](https://meta.discourse.org/t/how-to-add-analytics-and-pixel-scripts-avoiding-content-security-policy-xss/321022/3 "2024-09-07T23:42:36Z")

</div>

I recently added PostHog to several sites and didn’t need to change any CSP settings. (I haven’t tried Facebook Pixel. It might help to add one thing at a time.) My technique was to use a Theme Component:

> **[Starting using PostHog with Discourse](https://beta.buildcivitas.com/t/starting-using-posthog-with-discourse/203)**
>
> PostHog works as a replacement for Google Analytics if you don’t want to share your visitors’ data with Google. It also adds a lot of other features such as being able to capture session recordings and JavaScript events out of the box. After...

> [@illusionandcards](#):
>
> I’ve even disabled the Content Security Policy and added “unsafe-eval” con scripts src, but it’s still not working.

That’s a strong signal CSP isn’t the problem.

Try starting with just PostHog in the beginning and see if that works. If it does, try just Meta Pixel.

For what it’s worth, the PostHog toolbar doesn’t work out of the box with Discourse. See:

> **[Toolbar not loading or displaying - Toolbar - Docs - PostHog](https://posthog.com/docs/toolbar#toolbar-not-loading-or-displaying)**
>
> Note: The PostHog toolbar is only available for the JavaScript web SDK. | Note: The PostHog toolbar is only available for the JavaScript web SDK . The toolbar is like "Inspect Element" for PostHog features and data. When…

---

_[View the full topic](https://meta.discourse.org/t/how-to-add-analytics-and-pixel-scripts-avoiding-content-security-policy-xss/321022)._
