How to use the react-ga.initialize function in react-ga

To help you get started, we’ve selected a few react-ga examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github desko27 / smash-tier-list / src / containers / SmashTierList.jsx View on Github external
// ui pieces
import SuperTitle from '../components/SuperTitle';
import GameSelect from '../components/GameSelect';
import Filter from '../components/Filter';
import HeaderIcon from '../components/HeaderIcon';
import Game from './Game';
import Notices from './Notices';


// environment vars
const env = process.env.REACT_STATIC_ENV;

// init google analytics
if (typeof document !== 'undefined' && env === 'production') {
  ReactGA.initialize('UA-69148909-3');
  ReactGA.pageview(window.location.pathname + window.location.search);
}

// add all the games to the redux store
if (store.getState().games.length === 0) {
  gamesData.forEach(game => store.dispatch(addGame(game)));
}

class SmashTierList extends React.Component {
  constructor(props) {
    super();
    const {
      dispatch,
      currentGame,
      history,
      route,
github shalomeir / snippod-boilerplate / snippod_webapp / client / scripts / main.js View on Github external
import React from 'react'
import { Router, Route, Link } from 'react-router'

import history from './utils/History.js'
//location: process.env.NODE_ENV === 'production' ? HashLocation : HistoryLocation,

//var router = require('./router'),
var routes = require('./routes'),
    UIActions = require('./actions/commons/UIActions');

var attachFastClick = require('fastclick'),
    ga = require('react-ga'),
    GA_TRACKING_ID = require('./constants/defaults').GA_TRACKING_ID;

ga.initialize(GA_TRACKING_ID);

/* jshint ignore:start */
React.render({routes}, document.getElementById('app-wrapper'))

//router.run((Handler, state) => {
//  ga.pageview(state.path);
//  React.render(, document.getElementById('app-wrapper'));
//});
/* jshint ignore:end */

// for google analytics pageview
history.listen(function (location) {
  ga.pageview(location.pathname);
});
github RyanCCollins / ryancollinsio / client / app / src / routes.js View on Github external
import React from 'react';
import { Router } from 'react-router';
import { ApolloProvider } from 'react-apollo';
import ReactGA from 'react-ga';
import { AppContainer } from 'containers'; // eslint-disable-line
import client from './apolloClient';
import store, { history } from './store';

// initialize google analytics
if (typeof window !== 'undefined') {
  ReactGA.initialize('UA-75828309-1');
}

/* eslint-disable */
// Polyfill for the System.import for webpack
if (typeof System === 'undefined') {
  var System = {
    import(path) {
      return Promise.resolve(require(path));
    },
  };
}
/* eslint-enable */

// Switching to system.import to make use of dynamic tree shaking
// https://medium.com/modus-create-front-end-development/automatic-code-splitting-for-react-router-w-es6-imports-a0abdaa491e9#.msrxv8fwd
const errorLoading = err =>
github madox2 / react-tagcloud / examples / src / analytics.js View on Github external
import ReactGA from 'react-ga'

if (process.env.NODE_ENV !== 'production') {
  ReactGA.initialize('UA-000000-01', { debug: true })
} else {
  ReactGA.initialize('UA-87163647-1')
}

const pageview = () => ReactGA.pageview('/')

const codeExpanded = () =>
  ReactGA.event({
    category: 'User',
    action: 'Expanded Code Preview',
  })

const analytics = { pageview, codeExpanded }

export default analytics
github devsonket / devsonket.github.io / src / App.js View on Github external
constructor(props) {
    super(props);

    ReactGA.initialize("UA-129387050-1", { testMode: props.isTestMode });
    (process.env.NODE_ENV && (process.env.NODE_ENV !== 'development' && navigator.userAgent !== 'ReactSnap')) && ReactGA.pageview(window.location.href);
  }
github ensdomains / ens-manager / src / Main.js View on Github external
import DomainManager from './pages/DomainManager'
import ReverseRecord from './pages/ReverseRecord'
import Notifications from './components/Notifications'
//import Tracker from '../components/Tracker'

import createHistory from 'history/createBrowserHistory'

import ReactGA from 'react-ga';

import { db } from 'redaxe'
import {
  BrowserRouter as Router,
  Route
} from 'react-router-dom'

ReactGA.initialize('UA-101611202-1');

const history = createHistory()
history.listen((location, action) => {
  ReactGA.set({ page: location.pathname });
  ReactGA.pageview(location.pathname);
});

const Main = () => {
  return <div>
    
      <div>
        
        
      </div>
    
    </div>
github jamesmfriedman / rmwc / src / rmwc / docs / index.tsx View on Github external
const initAnalytics = () => {
  ReactGA.initialize(process.env.REACT_APP_GOOGLE_ANALYTICS_ID as string);
  const doPageView = () =>
    ReactGA.pageview(window.location.pathname + window.location.search);
  history.listen(() => doPageView());
  doPageView();
};
github iotaledger / industry-marketplace / YellowPages / client / src / index.js View on Github external
import React from 'react';
import ReactDOM from 'react-dom';
import ReactGA from 'react-ga';
import App from './App';
import { googleAnalyticsId } from './config.json';
import './assets/styles/index.scss'

ReactGA.initialize(googleAnalyticsId);
ReactGA.set({ anonymizeIp: true });

ReactDOM.render(, document.getElementById('root'));
github prescottprue / generator-react-firebase / generators / app / templates / src / utils / analytics.js View on Github external
function initGA() {
  if (analyticsTrackingId) {
    ReactGA.initialize(analyticsTrackingId)
    ReactGA.set({
      appName: environment || 'Production',
      appVersion: version
    })
  }
}