react-ga/react-ga

Location parameter in ReactGA.pageview function.

Open

#210 建立於 2018年1月4日

在 GitHub 查看
 (8 留言) (6 反應) (0 負責人)JavaScript (5,116 star) (473 fork)batch import
ga integration buggood first issue

描述

Hi all, in my React App I use ReactGA.initialize and ReactGA.pageview on the first page rendered and ReactGA.pageview on every route change.

If I open my react application in a route different from the root, like this one:

/my-folder

GA Debug returns me in console:

location: http://myreactapp.com/my-folder
page: /my-folder

On every following route change, the page value changes correctly its value, but the location doesn't change, like this:

location: http://myreactapp.com/my-folder
page: /my-second-route-folder
---
location: http://myreactapp.com/my-folder
page: /my-third-route-folder
---

Is this correct? Or I have to update also the location in this way?

ReactGA.ga('send', {
  hitType: 'pageview',
  location: `${window.location.protocol}//${window.location.host}/`,
  page: window.location.pathname,
});

貢獻者指南