Skip to content

Commit

Permalink
updates google analytics for marketplace (#827)
Browse files Browse the repository at this point in the history
  • Loading branch information
scandycuz authored Nov 20, 2024
1 parent 2b189ab commit d66bdc9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
25 changes: 4 additions & 21 deletions apps/marketplace/src/components/GoogleAnalytics.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
import { FunctionComponent, useEffect } from "react";
import { FunctionComponent } from "react";
import { GA_MARKETPLACE_ID, isProd } from "@newm-web/env";
import ReactGA from "react-ga4";
import { useLocation } from "react-router-dom";

if (isProd && GA_MARKETPLACE_ID) {
ReactGA.initialize(GA_MARKETPLACE_ID);
}
import { GoogleAnalytics as NextJsGoogleAnalytics } from "@next/third-parties/google";

const GoogleAnalytics: FunctionComponent = () => {
const location = useLocation();

/**
* Send GA page view on each route change in production.
*/
useEffect(() => {
if (!isProd) return;

ReactGA.send({
hitType: "pageview",
page: location.pathname,
});
}, [location]);
if (!isProd || !GA_MARKETPLACE_ID) return null;

return null;
return <NextJsGoogleAnalytics gaId={ GA_MARKETPLACE_ID } />;
};

export default GoogleAnalytics;
18 changes: 18 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@mui/material": "^5.13.5",
"@mui/material-nextjs": "^5.15.6",
"@newm.io/cardano-dapp-wallet-connector": "^1.1.0",
"@next/third-parties": "^15.0.3",
"@react-oauth/google": "^0.11.0",
"@reduxjs/toolkit": "^2.1.0",
"@sentry/cli": "^2.21.2",
Expand Down

0 comments on commit d66bdc9

Please sign in to comment.