Include GA in a React project

Viewed 2376

I followed the documentation and I got to this code to add Google Analytics to my React app:

import 'autotrack'

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

But I get the following 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? Will I get all the data I currently get with the original GA snippet following this setting and is it worth it to implement code splitting (I'm using Webpack).

1 Answers
Related