fix(website): Use GTM for conversion tracking (#7154)

This commit is contained in:
Jamil
2024-10-23 22:38:36 -07:00
committed by GitHub
parent 12ca4f1cc7
commit dd37a6383f

View File

@@ -2,10 +2,9 @@
import { useEffect } from "react";
import { HubSpotSubmittedFormData } from "./types";
import { sendGTMEvent } from "@next/third-parties/google";
export default function GoogleAds() {
const trackingId = process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS_ID;
useEffect(() => {
const handleMessage = (event: MessageEvent) => {
if (
@@ -22,11 +21,12 @@ export default function GoogleAds() {
return;
};
(window as any).gtag("event", "conversion", {
send_to: `${trackingId}/1wX_CNmzg7MZEPyK3OA9`,
value: Number(formData.submissionValues["0-2/numberofemployees"]) * 5,
currency: "USD",
event_callback: callback,
const value =
Number(formData.submissionValues["0-2/numberofemployees"]) * 5;
sendGTMEvent({
event: "hubspot-form-submitted",
conversionValue: value,
});
}
};
@@ -36,7 +36,7 @@ export default function GoogleAds() {
return () => {
window.removeEventListener("message", handleMessage);
};
}, [trackingId]);
}, []);
return null;
}