Integrate Google Analytics Measurement Id with React JS

Viewed 4303

I am creating a new web project in Google Analytics.

  1. Why am i getting a Measurement iD instead of Tracking ID?
  2. How can i connect Measurement ID with React JS?
  3. Can i give localhost URL in website URL?

I have added below code in my App.js but it is not getting integrated with Google Analytics

useEffect(() => {
  ReactGA.initialize('G-*******SYL');
  ReactGA.pageview('/');
}, [])
2 Answers

I suggest you create a Universal Analytics Property (as shown in following image) and use the relative identifier UA-XXXXXXX-X because Google Analytics 4 Property ID (G-XXXXXXXX) currently has the measurement protocol in alpha version, also React does not support it yet:

enter image description here

Create a new property, with selected "Create a Universal Analytics property". It'll show you tracking id.

Related