From 27ce82de3b4989fe942bd6864e4124c3307b2b1e Mon Sep 17 00:00:00 2001 From: willyb321 Date: Tue, 12 Jun 2018 07:56:01 +1000 Subject: [PATCH] switch to google analytics from piwik --- package-lock.json | 9 +++++++++ package.json | 1 + src/app/Router.js | 7 +++---- src/index.ejs | 4 ++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index aef1dc9f..fd475056 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10760,6 +10760,15 @@ "prop-types": "^15.5.10" } }, + "react-ga": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/react-ga/-/react-ga-2.5.3.tgz", + "integrity": "sha512-25wvPv1PVLDLhw1gEYP33h0V2sJHahKMfUCAxhq8JPYmNQwx1fcjJAkJk+WmSqGN93lHLhExDkxy3SQizQnx3A==", + "requires": { + "prop-types": "^15.6.0", + "react": "^15.6.2 || ^16.0" + } + }, "react-measure": { "version": "1.4.7", "resolved": "https://registry.npmjs.org/react-measure/-/react-measure-1.4.7.tgz", diff --git a/package.json b/package.json index b94f160a..2d3ad871 100644 --- a/package.json +++ b/package.json @@ -109,6 +109,7 @@ "prop-types": "^15.5.8", "react": "^15.5.4", "react-dom": "^15.5.4", + "react-ga": "^2.5.3", "react-number-editor": "Athanasius/react-number-editor.git#miggy", "recharts": "^0.22.3", "superagent": "^3.5.2" diff --git a/src/app/Router.js b/src/app/Router.js index 6ac0e612..be225b3f 100644 --- a/src/app/Router.js +++ b/src/app/Router.js @@ -1,5 +1,6 @@ import Persist from './stores/Persist'; - +import ReactGA from 'react-ga'; +ReactGA.initialize('UA-55840909-18'); let standalone = undefined; /** @@ -257,9 +258,7 @@ Route.prototype.match = function(path, params) { * @param {string} path Path to track */ function gaTrack(path) { - if (window.ga) { - window.ga('send', 'pageview', path); - } + ReactGA.pageview(path); } /** diff --git a/src/index.ejs b/src/index.ejs index 8bb317f2..c89a866f 100644 --- a/src/index.ejs +++ b/src/index.ejs @@ -38,7 +38,7 @@ <% } %> - -->