How to use the react-ga.plugin 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 DefinitelyTyped / DefinitelyTyped / types / react-ga / react-ga-tests.ts View on Github external
it("Able to make plugin object calls", () => {
        const execute = ga.plugin.execute;
        const require = ga.plugin.require;
        const payload = {};

        execute('name', 'action', payload);
        execute('name', 'action', 'type', payload);
        require('name', {});
    });
    it("Able to make outboundLink calls", () => {
github DefinitelyTyped / DefinitelyTyped / types / react-ga / react-ga-tests.ts View on Github external
it("Able to make plugin object calls", () => {
        const execute = ga.plugin.execute;
        const require = ga.plugin.require;
        const payload = {};

        execute('name', 'action', payload);
        execute('name', 'action', 'type', payload);
        require('name', {});
    });
    it("Able to make outboundLink calls", () => {
github Icemic / search.bakery.moe / client / src / app.js View on Github external
import './app.css';
import Index from './pages/index.jsx';
import Item from './pages/item.jsx';
import About from './pages/about.jsx';
import Header from './components/header';
import Footer from './components/footer';

register('title', (state, action) => {
  const { value, page } = action;

  return `${value} - `;
});

ReactGA.initialize('UA-101128351-1');
ReactGA.plugin.require('displayfeatures');

const withTracker = (WrappedComponent) => {
  const trackPage = (page) => {
    ReactGA.set({ page });
    ReactGA.pageview(page);
    window._czc && window._czc.push(["_trackPageview", page]);
  };

  const HOC = (props) => {
    const page = props.location.pathname + props.location.search;
    trackPage(page);

    return (
      
    );
  };
github elasticpath / react-pwa-reference-storefront / app / src / utils / Analytics.tsx View on Github external
*
 *
 */

import React from 'react';
import ReactRouterPropTypes from 'react-router-prop-types';
import ga from 'react-ga';

import * as Config from '../ep.config.json';

const showCompliance = Config.Compliance.enable;
const isComplianceAccepted = (showCompliance ? localStorage.getItem(`${Config.cortexApi.scope}_Compliance_Accept`) : true);

if (Config.gaTrackingId !== '' && isComplianceAccepted) {
  ga.initialize(Config.gaTrackingId);
  ga.plugin.require('ec');
}

export default Component => class WithAnalytics extends React.Component {
  static propTypes = {
    history: ReactRouterPropTypes.history.isRequired,
    location: ReactRouterPropTypes.location.isRequired,
  }

  componentDidMount() {
    const { location } = this.props;
    const page = location.pathname;
    this.trackPageAnalytics(page);
  }

  componentWillReceiveProps(nextProps) {
    const { location } = this.props;
github elasticpath / react-pwa-reference-storefront / app / src / utils / Analytics.tsx View on Github external
export function trackAddImpression(nameInput, skuInput, priceInput, categoryInput, quantityInput) {
  ga.plugin.execute('ec', 'addImpression', {
    id: skuInput,
    name: nameInput,
    price: priceInput,
    category: categoryInput,
    quantity: quantityInput,
  });
}
github tadeuzagallo / blog / gatsby-browser.js View on Github external
import ReactGA from 'react-ga'
import {config} from 'config'

ReactGA.initialize(config.googleAnalyticsId);
ReactGA.plugin.require('linkid');

exports.onRouteUpdate = (state, page, pages) => {
  ReactGA.pageview(state.pathname);
};
github wellcometrust / wellcomecollection.org / common / utils / analytics.js View on Github external
ReactGA.set({'dimension2': category});
  };
  if (featuresCohort && featuresCohort !== 'default') {
    ReactGA.set({'dimension5': featuresCohort});
  }
  if (contentType) {
    ReactGA.set({'dimension6': contentType});
  }
  if (referringComponentListString) {
    ReactGA.set({'dimension7': referringComponentListString});
  }
  if (pageState && Object.keys(pageState).length > 0) {
    ReactGA.set({'dimension8': JSON.stringify(pageState)});
  };

  ReactGA.plugin.require('GTM-NXMJ6D9');
  const pageview = `${window.location.pathname}${window.location.search}`;
  ReactGA.pageview(pageview);

  Router.onRouteChangeStart = url => {
    window.performance.mark('onRouteChangeStart');
  };

  Router.onRouteChangeComplete = url => {
    window.performance.mark('onRouteChangeEnd');
    window.performance.measure(
      'onRouteChange',
      'onRouteChangeStart',
      'onRouteChangeEnd'
    );
    const measure = window.performance.getEntriesByName('onRouteChange')[0];
    ReactGA.timing({