From 326c15a9fc42a24e0765cb36bd9c3a0637ece266 Mon Sep 17 00:00:00 2001 From: Simon Reinsperger Date: Sun, 2 Oct 2016 15:06:54 +0200 Subject: [PATCH] Adds Google Analytics Support --- config.toml | 2 ++ gatsby-browser.js | 8 ++++++++ package.json | 6 +++--- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 gatsby-browser.js diff --git a/config.toml b/config.toml index d15ffdb..c4aaeeb 100644 --- a/config.toml +++ b/config.toml @@ -9,4 +9,6 @@ siteEmailUrl = "#" siteRssUrl = "#" siteVkUrl = "#" +googleAnalyticsId = "" + linkPrefix = "/gatsby-starter-lumen" \ No newline at end of file diff --git a/gatsby-browser.js b/gatsby-browser.js new file mode 100644 index 0000000..8ba7f29 --- /dev/null +++ b/gatsby-browser.js @@ -0,0 +1,8 @@ +import ReactGA from 'react-ga' +import {config} from 'config' + +ReactGA.initialize(config.googleAnalyticsId); + +exports.onRouteUpdate = (state, page, pages) => { + ReactGA.pageview(state.pathname); +}; \ No newline at end of file diff --git a/package.json b/package.json index bc59563..8319558 100644 --- a/package.json +++ b/package.json @@ -31,12 +31,12 @@ "gatsby": "^0.12.0", "history": "^2.1.1", "lodash": "^4.14.1", - "moment": "^2.14.1", "markdown-it": "^6.0.2", + "moment": "^2.14.1", "react": "^15.3.0", "react-document-title": "^2.0.2", "react-dom": "^15.3.0", - "react-google-analytics": "^0.2.0", + "react-ga": "^2.1.2", "react-router": "^2.6.1", "safe-access": "^0.1.0", "underscore.string": "^3.2.3" @@ -65,4 +65,4 @@ "rucksack-css": "^0.8.5", "lost": "^7.0.3" } -} \ No newline at end of file +}