site: enable GA

This commit is contained in:
Benjy Cui 2016-03-25 17:35:26 +08:00
parent 41460d615a
commit 6199cf158f

View File

@ -28,6 +28,22 @@ const redirects = Object.keys(config.redirects).map((from, index) => {
return <Redirect from={from} to={config.redirects[from]} key={index} />;
});
// Enable Google Analytics
if (!location.port) {
/* eslint-disable */
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-72788897-1', 'auto');
ga('send', 'pageview');
hashHistory.listen((loc) => {
ga('send', 'pageview', loc.pathname + loc.search);
});
/* eslint-enable */
}
ReactDOM.render(
<Router history={hashHistory}>
<Route path="/" component={App}>