Skip to content

Commit

Permalink
attach safaryClub script to header
Browse files Browse the repository at this point in the history
  • Loading branch information
zuies committed Sep 19, 2023
1 parent 24f49ad commit 81133de
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/components/global/SafaryClubScript.tsx
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 2 additions & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -41,6 +42,7 @@ export default function App({ Component, pageProps }: ComponentWithPageLayout) {
return (
<>
<AmplitudeAnalytics />
<SafaryClubScript />
<Script id="tawk" strategy="lazyOnload">
{`
var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
Expand Down

0 comments on commit 81133de

Please sign in to comment.