From 15d1f6340a5c18dc038f4c419a7fef7aedcbb586 Mon Sep 17 00:00:00 2001 From: haworku Date: Thu, 1 Feb 2024 16:21:54 -0800 Subject: [PATCH] Send utag.view tag data on initial app load (#2215) * Call utag.view also on initial app load * Cleanup --- services/app-web/src/hooks/useTealium.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/services/app-web/src/hooks/useTealium.ts b/services/app-web/src/hooks/useTealium.ts index c6bf8cec59..e0e833bcb3 100644 --- a/services/app-web/src/hooks/useTealium.ts +++ b/services/app-web/src/hooks/useTealium.ts @@ -90,10 +90,25 @@ const useTealium = (): { document.body.appendChild(loadTagsSnippet) + const tagData: TealiumViewDataObject = { + content_language: 'en', + content_type: `${CONTENT_TYPE_BY_ROUTE[currentRoute]}`, + page_name: tealiumPageName, + page_path: pathname, + site_domain: 'cms.gov', + site_environment: `${process.env.REACT_APP_STAGE_NAME}`, + site_section: `${currentRoute}`, + logged_in: `${Boolean(loggedInUser) ?? false}`, + } + window.utag.view(tagData) + return () => { // document.body.removeChild(loadTagsSnippet) document.head.removeChild(initializeTagManagerSnippet) } + + // NOTE: Run effect once on component mount, we recheck dependencies if effect is updated in the subsequent page view effect + // eslint-disable-next-line react-hooks/exhaustive-deps }, []) // Add page view