Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is this library dead? #53

Open
marioGMIT opened this issue Aug 23, 2022 · 13 comments
Open

is this library dead? #53

marioGMIT opened this issue Aug 23, 2022 · 13 comments

Comments

@marioGMIT
Copy link

Can anyone confirm if this library is still alive? For the comments that I'm reading here make me think that this doesn't work very well?

@Amethystafyy282
Copy link

does not work with GA4 for me. Debug sent work with every kind of GA Account ID even fake one. And does not firing any errors.

@johnnytomcat
Copy link

Works for me!

NOTE: TURN OFF YOUR ADBLOCK WHEN TESTING

In your App.js

import ReactGA4 from 'react-ga4';

ReactGA4.initialize("G-XXXXXX");

Create a usePageTracking.js

// usePageTracking.js
import { useEffect} from "react";
import { useLocation } from "react-router-dom";

const usePageTracking = () => {
  const location = useLocation();

  useEffect(() => {
    // track pageview with gtag / react-ga / react-ga4, for example:
    window.gtag("event", "page_view", {
      page_path: location.pathname + location.search,
    });
  }, [location]);
};

export default usePageTracking;

Make sure you add this inside your Router, mine is in my Navbar component.

//Navbar.js
const Navbar = () => {
  usePageTracking();

  return (...);
};

@wmonecke
Copy link

wmonecke commented Oct 20, 2022

Yeah, this library is dead. We should all be moving to firebase analytics.

Well maintained and implements GA4.

@boxabirds
Copy link

@wmonecke I'm not quite sure I understand: do firebase analytics work for other tech stacks? Or are you recommending anyone using ReactJS who wants GA support use Firebase?

@wmonecke
Copy link

wmonecke commented Nov 8, 2022

@boxabirds I say that for any tech stack

@echan00
Copy link

echan00 commented Nov 12, 2022

Works for me!

const usePageTracking = () => {
const location = useLocation();

useEffect(() => {
// track pageview with gtag / react-ga / react-ga4, for example:
window.gtag("event", "page_view", {
page_path: location.pathname + location.search,
});
}, [location]);
};

Hello! do you mean the following ReactGA.gtag? (Not window.gtag)

ReactGA.gtag("event", "page_view", {
  page_path: location.pathname + location.search,
});

@echan00
Copy link

echan00 commented Nov 12, 2022

Actually should be this now?


  useEffect(() => {
    // track pageview with gtag / react-ga / react-ga4, for example:
    ReactGA.send({ hitType: "pageview", page: location.pathname + location.search });
  }, [location]);

@wmonecke
Copy link

@echan00 why do you downvote my comment? The fact that it works doesn't mean it's being maintained. Do you know what that means?

@echan00
Copy link

echan00 commented Nov 13, 2022

@echan00 why do you downvote my comment? The fact that it works doesn't mean it's being maintained. Do you know what that means?

I don't mean anything personal but it seemed blanketing to use firebase (regardless of stack) seemed like a very opinionated comment.

@wmonecke
Copy link

Firebase is a Google Product. I am not promoting a third party service or wrapper.

@RayHughes
Copy link

RayHughes commented Dec 13, 2022

Stumbled on this. Should be an easy drop in if using nextjs https://github.com/MauricioRobayo/nextjs-google-analytics

@rawpixel-vincent
Copy link

thank you for your work on this @codler, works great when you need a simple upgrade path, and maintain the quality of the original library https://github.com/react-ga/react-ga

@codler
Copy link
Contributor

codler commented Jan 19, 2023

Moved to https://github.com/codler/react-ga4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants