diff --git a/package.json b/package.json index 1f47789..2daedbf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-google-analytics", - "version": "0.2.0", + "version": "0.2.1", "description": "Google Analytics component for React", "main": "./lib/index.js", "directories": { diff --git a/src/index.coffee b/src/index.coffee index ca72fe5..c7b597e 100644 --- a/src/index.coffee +++ b/src/index.coffee @@ -35,7 +35,9 @@ ga.Initializer = React.createClass el = document.createElement 'script' el.type = 'text/javascript' el.async = true - el.src = '//www.google-analytics.com/analytics.js' + protocol = window.location.href.split('/')[0]; + protocol = if protocol == 'chrome-extension:' then 'https:' else ''; + el.src = protocol + '//www.google-analytics.com/analytics.js'; s = document.getElementsByTagName('script')[0] s.parentNode.insertBefore el, s render: -> diff --git a/standalone/react-google-analytics.js b/standalone/react-google-analytics.js index 461e0ed..fc9600b 100644 --- a/standalone/react-google-analytics.js +++ b/standalone/react-google-analytics.js @@ -46,12 +46,14 @@ ga.Initializer = React.createClass({ } }, addScript: function() { - var el, s; + var el, protocol, s; scriptIsAdded = true; el = document.createElement('script'); el.type = 'text/javascript'; el.async = true; - el.src = '//www.google-analytics.com/analytics.js'; + protocol = window.location.href.split('/')[0]; + protocol = protocol === 'chrome-extension:' ? 'https:' : ''; + el.src = protocol + '//www.google-analytics.com/analytics.js'; s = document.getElementsByTagName('script')[0]; return s.parentNode.insertBefore(el, s); },