Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Analytics MIME type issue in Chrome using Rails 3

I'm adding GA to a Rails 3 app, which would normally be extremely simple, of course. I've added the GA JS snippet, which is rendering just fine. Everything works perfectly in Safari. In Chrome, however, it's giving me a console error: Resource interpreted as Script but transferred with MIME type text/html: "about:blank", pointing to the JS line that loads the ga.js file: s.parentNode.insertBefore(ga, s). Some things I've investigated:

  • I created a plan HTML page with the JS snippet, and it loads outside Rails in Chrome with no error.
  • The same HTML page, when put in /public, gives the error above.
  • The same HTML page, loaded in Safari from /public, doesn't give any error according to Firebug.
  • I tried the GA Debug extension in Chrome, but it remains silent, because ga.js isn't getting loaded.

Looking at the developer console in Chrome, I see a request for "http://www.google-analytics.com/ga.js" that seems to stay in "pending" state, and a redirect to "about:blank" seemingly initiated by http://www.google-analytics.com/ga.js, which makes very little sense.

So this seems to be related to Rails (since the snippet works in the HTML outside Rails), and doesn't affect Safari, but other than that I'm stumped. Hopefully I've just been staring at it wrong, and someone else will point out the obvious to me...? Anyone come across this before? Any ideas will be very much appreciated.

like image 369
Masonoise Avatar asked Mar 11 '13 23:03

Masonoise


1 Answers

Came across this issue myself. "Disconnect" disabled share buttons on my site (g+, twitter and fb). Had to remove it to view the site properly.

like image 192
ivan Avatar answered Oct 30 '22 16:10

ivan