Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8723971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:43:59+00:00 2026-06-13T07:43:59+00:00

When I realized that I cannot track directly in content script. I start to

  • 0

When I realized that I cannot track directly in content script. I start to work with background HTML tracking my data. via Content Script tracking with Google Analytics

When I set up my background script, I figured out that it doesn’t support inline script. So I put the code in a js file and use “src=filename.js” to include that. via chrome extension insert content script on browser action

But finally there is a trouble: I cannot load ga.js at all because it still violates the rule. Here is what I got:

Refused to load the script ‘https://ssl.google-analytics.com/ga.js‘
because it violates the following Content Security Policy directive:
“script-src ‘self’ chrome-extension-resource:”.

My extension structure:

  1. background.html
  2. script.js
  3. tracker.js

More information about this issue:

background.html:

<html>
<script src="tracker.js"></script>
<body></body>
</html>

tracker.js: (I hide my ID)

var _gaq = _gaq || [];
_gaq.push(['_setAccount', _gaID]);
_gaq.push(['_trackPageview']);

(function() {
  var ga = document.createElement('script');
  ga.type = 'text/javascript';
  ga.async = true;
  ga.src = 'https://ssl.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0];
  s.parentNode.insertBefore(ga, s);
})();

Thanks for any kind of help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:44:00+00:00Added an answer on June 13, 2026 at 7:44 am

    It looks good. You are on the right track. You just need to update your manifest.json file to allow scripts to be downloaded from the google domain.

    Assuming you are using manifest.json file with manifest_version:2. You should add this line to the manifest

    "content_security_policy": "script-src 'self' https://ssl.google-analytics.com; object-src 'self'",
    

    More info:

    https://developer.chrome.com/docs/extensions/mv2/tut_analytics/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realized that you cannot just insert <iframe src=remote-page-here></iframe> and expect it to work,
I realized that my application doesn't show up in searches on Google Play if
Today I realized that I no longer have a Web Content Form option (where
I just realized that I need to synchronize a significant amount of data collection
More and more I realized that without jumping into the code details, I cannot
I have application reads in data from text file. Recently I realized that I
After reading this post i realized that i cannot pass an anonymous type as
I just realized that in Eclipse one cannot collapse code blocks like {} .
I just threw this little mouse tracking example together when I realized, that it
I realize that enum cannot be used as a generic constraint, and Microsoft has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.