Skip to content

Commit

Permalink
Update to GA4
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerkrewson committed Jul 30, 2024
1 parent f91a72d commit c0d8ba9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 31 deletions.
32 changes: 6 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"nookies": "^2.5.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-ga": "^3.3.1",
"react-ga4": "^2.1.0",
"sass": "^1.77.8",
"skeleton-css": "^2.0.4",
"socket.io": "^4.7.5",
Expand Down
11 changes: 7 additions & 4 deletions utils/analytics.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import ReactGA from "react-ga";
import ReactGA from "react-ga4";

export const initGA = () => {
ReactGA.initialize("UA-82444397-11");
ReactGA.initialize("G-1VH05G01VY");
};

export const logPageView = () => {
ReactGA.set({ page: window.location.pathname });
ReactGA.pageview(window.location.pathname);
ReactGA.send({
hitType: "pageview",
});
};

export const logEvent = (category = "", action = "") => {
Expand All @@ -17,6 +19,7 @@ export const logEvent = (category = "", action = "") => {

export const logException = (description = "", fatal = false) => {
if (description) {
ReactGA.exception({ description, fatal });
// https://github.com/codler/react-ga4/issues/40
// ReactGA.exception({ description, fatal });
}
};

0 comments on commit c0d8ba9

Please sign in to comment.