reverted GA component
This commit is contained in:
parent
c4ccc9a361
commit
0aa78efa5d
6 changed files with 58841 additions and 43 deletions
10961
index.js
10961
index.js
File diff suppressed because one or more lines are too long
47866
public/bundle/bundle.js
47866
public/bundle/bundle.js
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
|||
import React from 'react';
|
||||
import NavBar from 'containers/NavBar/index';
|
||||
import NavBar from 'containers/NavBar';
|
||||
import Helmet from 'react-helmet';
|
||||
|
||||
class FourOhForPage extends React.Component {
|
||||
|
|
|
@ -1,10 +1,23 @@
|
|||
import { connect } from 'react-redux';
|
||||
import View from './view';
|
||||
import React from 'react';
|
||||
import GoogleAnalytics from 'react-ga';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
|
||||
const mapStateToProps = ({ site: { googleAnalyticsId } }) => {
|
||||
return {
|
||||
googleAnalyticsId,
|
||||
};
|
||||
};
|
||||
GoogleAnalytics.initialize('test');
|
||||
|
||||
export default connect(mapStateToProps, null)(View);
|
||||
class GAListener extends React.Component {
|
||||
componentDidMount () {
|
||||
this.sendPageView(this.props.history.location);
|
||||
this.props.history.listen(this.sendPageView);
|
||||
}
|
||||
|
||||
sendPageView (location) {
|
||||
GoogleAnalytics.set({ page: location.pathname });
|
||||
GoogleAnalytics.pageview(location.pathname);
|
||||
}
|
||||
|
||||
render () {
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
export default withRouter(GAListener);
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
import React from 'react';
|
||||
import GoogleAnalytics from 'react-ga';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
|
||||
class GAListener extends React.Component {
|
||||
componentDidMount () {
|
||||
// initiate analytics
|
||||
const { googleAnalyticsId } = this.props;
|
||||
if (googleAnalyticsId) {
|
||||
GoogleAnalytics.initialize(googleAnalyticsId);
|
||||
this.sendPageView(this.props.history.location);
|
||||
this.props.history.listen(this.sendPageView);
|
||||
}
|
||||
}
|
||||
|
||||
sendPageView (location) {
|
||||
GoogleAnalytics.set({ page: location.pathname });
|
||||
GoogleAnalytics.pageview(location.pathname);
|
||||
}
|
||||
|
||||
render () {
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
export default withRouter(GAListener);
|
Loading…
Reference in a new issue