From 0ae7b08ec1e7b155304441dda821efa0ceee4f7c Mon Sep 17 00:00:00 2001 From: Ramin Farhadi Date: Wed, 24 Jul 2024 15:35:30 -0400 Subject: [PATCH] customEventType added in order to load custom dimentions. --- src/App.tsx | 9 ++++++--- src/types/CustomEventOptions.ts | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 src/types/CustomEventOptions.ts diff --git a/src/App.tsx b/src/App.tsx index 4cc79f0..508fcfc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -67,6 +67,7 @@ import { Visibility } from './types/Visibility'; // Data Imports import campusData from './assets/campuses.json'; +import { CustomEventOptions } from './types/CustomEventOptions'; const TOKEN = import.meta.env.VITE_MAPBOX_TOKEN; const FOOTER_MENU_ID = import.meta.env.VITE_REMOTE_FOOTER_MENU_ID; @@ -205,14 +206,16 @@ function App() { if (response.length > 0) { const location = response.pop(); - ReactGA.event({ + + const internalLinkClickGa4: CustomEventOptions = { category: "link", action: "click_internal_link", label: `${location!.title.rendered}`, - },{ link_url: `${location!.link}`, link_text: `${location!.title.rendered}` - }) + } + + ReactGA.event(internalLinkClickGa4) html = `${feature?.properties?.Name}`; } else { diff --git a/src/types/CustomEventOptions.ts b/src/types/CustomEventOptions.ts new file mode 100644 index 0000000..62613f9 --- /dev/null +++ b/src/types/CustomEventOptions.ts @@ -0,0 +1,6 @@ +import { UaEventOptions } from "react-ga4/types/ga4" + +export interface CustomEventOptions extends UaEventOptions { + link_url: string, + link_text: string +}