googleanalytics / autotrack

Automatic and enhanced Google Analytics tracking for common user interactions on the web.
Other
4.93k stars 563 forks source link

ga not defined #179

Closed marcogreselin closed 7 years ago

marcogreselin commented 7 years ago

Hello!

I have an app created with create-react-app and I wanted to add GA. I just followed your doc and added this to my index.js file:


import 'autotrack'

ga('create', 'MY ID', 'auto');
ga('require', 'urlChangeTracker')
ga('send', 'pageview')

after having ran an npm install autotrack --save. but I get this error:

  Line 11:  'ga' is not defined  no-undef
  Line 12:  'ga' is not defined  no-undef
  Line 13:  'ga' is not defined  no-undef

How can I solve it? Thanks!

philipwalton commented 7 years ago

This error is coming from eslint, so you'll need to add something to your eslint config to suppress it.

Here's an example from one of my projects: https://github.com/philipwalton/analyticsjs-boilerplate/blob/master/.eslintrc#L12-L14