From 81133dedeb47c7743f4e3e4aa5c5e4c69671e877 Mon Sep 17 00:00:00 2001 From: zuies Date: Tue, 19 Sep 2023 10:53:06 +0300 Subject: [PATCH] attach safaryClub script to header --- src/components/global/SafaryClubScript.tsx | 21 +++++++++++++++++++++ src/pages/_app.tsx | 2 ++ 2 files changed, 23 insertions(+) create mode 100644 src/components/global/SafaryClubScript.tsx diff --git a/src/components/global/SafaryClubScript.tsx b/src/components/global/SafaryClubScript.tsx new file mode 100644 index 00000000..fba0c863 --- /dev/null +++ b/src/components/global/SafaryClubScript.tsx @@ -0,0 +1,21 @@ +import { useEffect } from 'react'; + +const SafaryClubScript = () => { + useEffect(() => { + if (process.env.NODE_ENV === 'production') { + const script = document.createElement('script'); + script.src = 'https://tag.safary.club/stag.js?id=prd_3F8QxipEOt'; + script.async = true; + document.head.appendChild(script); + + // Cleanup on component unmount + return () => { + document.head.removeChild(script); + }; + } + }, []); + + return null; +}; + +export default SafaryClubScript; diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 48cbb4ac..cd49631d 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -23,6 +23,7 @@ import { conf } from '../configs'; import AmplitudeAnalytics from '../components/global/AmplitudeAnalytics'; import Script from 'next/script'; import { usePageViewTracking } from '../helpers/amplitudeHelper'; +import SafaryClubScript from '../components/global/SafaryClubScript'; export default function App({ Component, pageProps }: ComponentWithPageLayout) { usePageViewTracking(); @@ -41,6 +42,7 @@ export default function App({ Component, pageProps }: ComponentWithPageLayout) { return ( <> +