website/components/analitycs/index.ts
2024-04-29 23:13:00 -06:00

31 lines
651 B
TypeScript

"use client";
import ReactGA from "react-ga4";
const initializeGA = () => {
// Replace with your Measurement ID
// It ideally comes from an environment variable
ReactGA.initialize("G-0RTZ5EPB26");
// Don't forget to remove the console.log() statements
// when you are done
};
interface Props {
category: string;
action: string;
label: string;
}
const trackGAEvent = ({ category, action, label }: Props) => {
console.log("GA event:", category, ":", action, ":", label);
// Send GA4 Event
ReactGA.event({
category: category,
action: action,
label: label,
});
};
export default initializeGA;
export { initializeGA, trackGAEvent };