From 6199cf158fcf55ae4d9073c002492ac00a96c33a Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Fri, 25 Mar 2016 17:35:26 +0800 Subject: [PATCH] site: enable GA --- site/entry/index.jsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/site/entry/index.jsx b/site/entry/index.jsx index e2e8f5875b..70b37e1040 100644 --- a/site/entry/index.jsx +++ b/site/entry/index.jsx @@ -28,6 +28,22 @@ const redirects = Object.keys(config.redirects).map((from, index) => { return ; }); +// 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( -- GitLab