@shopify/react-google-analytics
Google Analytics
Last updated 13 days ago by shopify-dep .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @shopify/react-google-analytics 
SYNC missed versions from official npm registry.

@shopify/react-google-analytics

Build Status License: MIT npm version npm bundle size (minified + gzip)

Allows React apps to easily embed tracking pixel iframes

Installation

$ yarn add @shopify/react-google-analytics

Usage

This library exports a <Universal /> & a <GaJS /> component, which allows React apps to easily embed Google Analytics scripts.

analytics.js example


import {Universal} from '@shopify/react-google-analytics';

const UNIVERSAL_GA_ACCOUNT_ID = 'UA-xxxx-xx';

<Universal
  account={UNIVERSAL_GA_ACCOUNT_ID}
  domain={shopDomain}
  disableTracking
  debug
  // NOTE: This prop will load and set the debug mode for Google Analytics
  // https://developers.google.com/analytics/devguides/collection/analyticsjs/debugging
/>;

Set custom variables for analytics.js

import {Universal} from '@shopify/react-google-analytics';

const UNIVERSAL_GA_ACCOUNT_ID = 'UA-xxxx-xx';

<Universal
  account={UNIVERSAL_GA_ACCOUNT_ID}
  domain={shopDomain}
  set={{
    foo: 'bar', // This translates to ga('set', 'foo', 'bar');
  }}
/>;

Getting access to the universal tracking instance

import {Universal} from '@shopify/react-google-analytics';

const UNIVERSAL_GA_ACCOUNT_ID = 'UA-xxxx-xx';

<Universal
  account={UNIVERSAL_GA_ACCOUNT_ID}
  domain={shopDomain}
  onLoad={ga => {
    this.ga = ga;
  }}
/>;

<button
  onClick={() => {
    this.ga('send', 'event', 'Videos', 'play', 'Cool Video');
  }}
>
  Play Video
</button>;

For more info on using analytics.js see the documentation

ga.js example


WARNING: ga.js is a legacy library. If you are starting a new implementation, we recommend you use the latest version of this library, analytics.js.

import {GaJS} from '@shopify/react-google-analytics';

const GA_JS_ACCOUNT_ID = 'UA-xxxx-xx';

<GaJS
  account={GA_JS_ACCOUNT_ID}
  domain={shopDomain}
  disableTracking
  // NOTE: Disables the tracking snippet from sending data to Google Analytics.
  // https://developers.google.com/analytics/devguides/collection/gajs/#disable
/>;

Set custom variables for ga.js

import {GaJS} from '@shopify/react-google-analytics';

const GA_JS_ACCOUNT_ID = 'UA-xxxx-xx';

<GaJS
  account={GA_JS_ACCOUNT_ID}
  domain={shopDomain}
  set={{
    foo: 'bar', // This translates to _gaq.push(['foo', 'bar']);
  }}
/>;

Getting access to the ga tracking instance

import {GaJS} from '@shopify/react-google-analytics';

const GA_JS_ACCOUNT_ID = 'UA-xxxx-xx';

<GaJS
  account={GA_JS_ACCOUNT_ID}
  domain={shopDomain}
  onLoad={_gaq => {
    this._gaq = _gaq;
  }}
/>;

<button
  onClick={() => {
    this._gaq.push(['_trackEvent', 'button3', 'clicked']);
  }}
>
  Play Video
</button>;

For more info on using ga.js see the documentation

Current Tags

  • 3.0.19                                ...           latest (13 days ago)

44 Versions

  • 3.0.19                                ...           13 days ago
  • 3.0.18                                ...           16 days ago
  • 3.0.17                                ...           25 days ago
  • 3.0.16                                ...           a month ago
  • 3.0.15                                ...           4 months ago
  • 3.0.14                                ...           4 months ago
  • 3.0.13                                ...           4 months ago
  • 3.0.12                                ...           5 months ago
  • 3.0.11                                ...           5 months ago
  • 3.0.10                                ...           5 months ago
  • 3.0.9                                ...           5 months ago
  • 3.0.8                                ...           5 months ago
  • 3.0.7                                ...           5 months ago
  • 3.0.6                                ...           5 months ago
  • 3.0.5                                ...           5 months ago
  • 3.0.4                                ...           5 months ago
  • 3.0.3                                ...           5 months ago
  • 3.0.2                                ...           5 months ago
  • 3.0.1                                ...           5 months ago
  • 3.0.0                                ...           5 months ago
  • 2.2.12                                ...           6 months ago
  • 2.2.11                                ...           6 months ago
  • 2.2.10                                ...           6 months ago
  • 2.2.9                                ...           6 months ago
  • 2.2.8                                ...           6 months ago
  • 2.2.7                                ...           6 months ago
  • 2.2.6                                ...           6 months ago
  • 2.2.4                                ...           7 months ago
  • 2.2.3                                ...           7 months ago
  • 2.2.2                                ...           7 months ago
  • 2.2.1                                ...           7 months ago
  • 2.2.0                                ...           8 months ago
  • 2.1.0                                ...           8 months ago
  • 2.0.0                                ...           8 months ago
  • 1.1.3                                ...           8 months ago
  • 1.1.2                                ...           9 months ago
  • 1.1.1                                ...           9 months ago
  • 1.1.0                                ...           9 months ago
  • 1.0.1                                ...           10 months ago
  • 1.0.0                                ...           a year ago
  • 0.1.3                                ...           a year ago
  • 0.1.2                                ...           a year ago
  • 0.1.1                                ...           a year ago
  • 0.1.0                                ...           a year ago
Downloads
Today 0
This Week 44
This Month 123
Last Day 0
Last Week 63
Last Month 82
Dependencies (2)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |