Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
4 changes: 3 additions & 1 deletion src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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: ->
Expand Down
6 changes: 4 additions & 2 deletions standalone/react-google-analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down