Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReactGA not working for G type tracking Id

I am trying to implement google analytics in my reaact application. But does give any page hit in analytics dashboard.

Here is the implementation: In App.js:

import ReactGA from "react-ga";
 componentDidMount() {
    ReactGA.initialize("G-QBQXxxxxx");
    ReactGA.pageview("/")
  }

Anything wrong in my implementation ?

like image 694
Nishant_061 Avatar asked Dec 14 '22 08:12

Nishant_061


1 Answers

Based on react-ga docs, it is designed to work with Universal Analytics which was the latest version of Google Analytics until Oct 14, 2020. Since then, GA-4 is the default property type in Google Analytics. You need to create a property of type Universal Analytics. To do so, go to Google Analytics Home page and go to Admin.

enter image description here

Select the Account that you want to add a Property to and click on Create Property.

enter image description here

Now you proceed to Property setup page. (Also you could have created a new Account and after setting its name in the second step you would have seen Property Setup). Then click on Show advanced options.

enter image description here

Enable Create a Universal Analytics property and select one of the available options. If you select Create both a Google Analytics 4 and a Universal Analytics property, you will have two different properties one having a MEASUREMENT ID like GA-XXXXXXXXXX and another having a Tracking ID like UA-XXXXXXXXXX. Use the Tracking ID instead of MEASUREMENT ID.

enter image description here

like image 200
Abdollah Avatar answered Dec 23 '22 17:12

Abdollah