Title: Javascript and Content Security Policy
Last modified: May 6, 2024

---

# Javascript and Content Security Policy

 *  Resolved [sethbburgess](https://wordpress.org/support/users/sethbburgess/)
 * (@sethbburgess)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/javascript-and-content-security-policy/)
 * I have a website on AWS Lightsail Bitnami Apache WordPress. I am setting up a
   Content Security Policy. It appears that the Monsterinsights version of Google
   Analytics uses some “inline” javascripts. Inline scripts are not allowed in a
   Content Security Policy. I need to move these scripts to a javascript file and
   call them from that file instead of having them appear inline. I am not sure 
   where and how to make this change.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fjavascript-and-content-security-policy%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Support [Michelle D.](https://wordpress.org/support/users/devmich/)
 * (@devmich)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/javascript-and-content-security-policy/#post-17746850)
 * Hi [@sethbburgess](https://wordpress.org/support/users/sethbburgess/),
 * Thanks for reaching out.
 * We don’t currently have a way to customize the output of our frontend tracking,
   I’m sorry about that! This will need to be handled by a separate plugin that 
   specializes in site optimization, and offers an option to move inline scripts
   to external JavaScript files.
 * That being said, we typically recommend excluding MonsterInsights or Google Analytics
   from being modified or optimized, as affecting the tracking scripts in this way
   may prevent MonsterInsights from working as expected.
 * Let me know if you have further questions.
 * Thank you.
 *  Thread Starter [sethbburgess](https://wordpress.org/support/users/sethbburgess/)
 * (@sethbburgess)
 * [2 years ago](https://wordpress.org/support/topic/javascript-and-content-security-policy/#post-17752038)
 * Thanks so much for your reply. My concern is not so much with combining script
   files. It is more about ensuring compatibility between google tag manager and
   my content security policy. I found this article: [https://www.bounteous.com/insights/2017/07/20/using-google-analytics-and-google-tag-manager-content-security-policy](https://www.bounteous.com/insights/2017/07/20/using-google-analytics-and-google-tag-manager-content-security-policy).
   I am not sure if this approach will work with monsterinsights. I am working on
   it.
 *  Plugin Support [Michelle D.](https://wordpress.org/support/users/devmich/)
 * (@devmich)
 * [2 years ago](https://wordpress.org/support/topic/javascript-and-content-security-policy/#post-17757858)
 * Hi [@sethbburgess](https://wordpress.org/support/users/sethbburgess/),
 * Thanks for the details. In that case, the best approach will be to allow the 
   MonsterInsights inline scripts to run and not be blocked by CSP restrictions.
 * I hope that helps, but let me know how I can continue to assist.
 * Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Javascript and Content Security Policy’ is closed to new replies.

 * ![](https://ps.w.org/google-analytics-for-wordpress/assets/icon.svg?rev=2976619)
 * [MonsterInsights - Google Analytics Dashboard for WordPress (Website Stats Made Easy)](https://wordpress.org/plugins/google-analytics-for-wordpress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/google-analytics-for-wordpress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/google-analytics-for-wordpress/)
 * [Active Topics](https://wordpress.org/support/plugin/google-analytics-for-wordpress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/google-analytics-for-wordpress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/google-analytics-for-wordpress/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Michelle D.](https://wordpress.org/support/users/devmich/)
 * Last activity: [2 years ago](https://wordpress.org/support/topic/javascript-and-content-security-policy/#post-17757858)
 * Status: resolved