-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MRKT-182: Adds Google Analytics for Marketplace (#780)
* Adds Google Analytics for Marketplace * adds ga marketplace id to cdk app
- Loading branch information
Showing
7 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { FunctionComponent, useEffect } 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); | ||
} | ||
|
||
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]); | ||
|
||
return null; | ||
}; | ||
|
||
export default GoogleAnalytics; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters