Skip to main content

All Questions

130 votes
17 answers
122k views

How to use google analytics with next.js app?

I'm using styled-components with next.js so my styles need to be server-side rendered, hence how can I add google analytics to my website? I checked next.js google analytics example but as I said my ...
0xsh's user avatar
  • 1,595
121 votes
16 answers
90k views

How to set up Google Analytics for React-Router?

I'm trying set up Google Analytics on my react site, and have come across a few packages, but none of which has the kind of set up that I have in terms of examples. Was hoping someone could shed some ...
John Fu's user avatar
  • 1,832
91 votes
9 answers
119k views

Adding Google Analytics to React

I am trying to add Google Analytics to a React Web Application. I know how to do it in HTML/CSS/JS sites and I have integrated it in an AngularJS app too. But, I'm not quite sure how to go about it ...
Raj's user avatar
  • 4,109
41 votes
10 answers
47k views

Google Analytics 4 with React

I've been trying to use react-ga package with google analytics 4 in my app. The measurement id doesn't work with it and there is no tracking code in google analytics 4 I can use. Please, I need help! ...
iMyke's user avatar
  • 623
25 votes
2 answers
33k views

React + Router + Google Tag Manager

I've been spending a bit of time developing an MVP at quickcypher.com. I wanted to start putting in some analytics, and it worked great for just tracking total visits, but things went south when I ...
SleepyProgrammer's user avatar
22 votes
3 answers
14k views

How set up a Gatsby Cookie consent banner with gatsby-plugin-gdpr-cookies

My website gathers information for Google Analytics, so I need to include a Cookie consent banner for the users to opt in/out of. I saw the plugin gatsby-plugin-gdpr-cookies and thought it looked ...
James Brightman's user avatar
19 votes
5 answers
10k views

Google analytics with react is not working

I am using google analytics in my react project and it doesn't show any active users even when I am online. I have tried different approaches that I found online but none seem to work. I have only ...
excurbia's user avatar
  • 381
16 votes
2 answers
13k views

ReactGA.initialize must be called first

I am getting the following warning multiple times (for multiple pages) despite me initializing at the root of my app. This makes me wonder if google analytics is even working properly? [react-ga] ...
Matt Strom's user avatar
15 votes
5 answers
15k views

TypeError: Illegal Invocation

We're running a Create React App (CRA) web app, to which we've added Google Analytics v4. We initiate analytics using the ga-4-react npm package. Manual initialization in index.js const ga4react = new ...
user avatar
13 votes
2 answers
30k views

How to set the Google Analytics cookie only after another consent cookie is set and "true"?

I am using React/Nextjs for my website and the react-cookie-consent library. It creates a pop up where the user can agree to the cookie policy. If agreed, a cookie is set: CookieConsent with value "...
flo's user avatar
  • 671
12 votes
4 answers
12k views

How to set up analytics on React Native for iOS

So I have a completed React Native project for iOS but I want to put analytics in it. I tried the react-native-google-analytics package, but issues prevent it from working properly. Also, the react-...
Tom Goldenberg's user avatar
11 votes
3 answers
9k views

Google Analytic GA4 does not disable default page_view event in React Application

I'm trying to add Google Analytics GA4 to a React Application, index.html <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} ...
usertest's user avatar
  • 2,272
11 votes
1 answer
9k views

How to handle cookie consent in Next JS?

On my Next JS website I needed to implement Google Analytics (GA) and Facebook Pixel (FP), which I did according to the documentation and is working as far as I can tell. Now, I need to make ...
round_circle's user avatar
  • 1,025
10 votes
5 answers
7k views

How to set up Google Analytics 4 for React-Router?

I'm trying to set up Google Analytics 4 on my react site. Previously I used react-ga, but this library doesn't support Google Analytics 4 yet. I pasted the GA4 tag directly into the index.html file ...
SpoKaPh's user avatar
  • 167
9 votes
7 answers
20k views

How to use Google Analytics with React?

In my react app I have some pages: Main Service Contact Profile (private) etc.. I need to track users activity with Google Analytics. I googled react-ga and it's just fine. But with this library I ...
Nastro's user avatar
  • 1,769

15 30 50 per page
1
2 3 4 5
19