Skip to content

Commit cc51690

Browse files
committed
feat(website): integrate Facebook Pixel and restructure Google Analytics components
1 parent 4e85d84 commit cc51690

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

apps/website/.env.template

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ ENABLE_SERVICE_WORKER=false
4040

4141
NEXT_PUBLIC_MEASUREMENT_ID=
4242

43+
#######################################################################################
44+
# Facebook Pixel #
45+
#######################################################################################
46+
47+
NEXT_PUBLIC_PIXEL_ID=
48+
4349
#######################################################################################
4450
# Intlayer #
4551
#######################################################################################
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Script from 'next/script';
2+
3+
const FacebookPixel = () => (
4+
<>
5+
<Script id="fb-pixel-init" strategy="afterInteractive">
6+
{`
7+
!function(f,b,e,v,n,t,s)
8+
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
9+
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
10+
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
11+
n.queue=[];t=b.createElement(e);t.async=!0;
12+
t.src=v;s=b.getElementsByTagName(e)[0];
13+
s.parentNode.insertBefore(t,s)}(window, document,'script',
14+
'https://connect.facebook.net/en_US/fbevents.js');
15+
fbq('init', '${process.env.NEXT_PUBLIC_PIXEL_ID}');
16+
fbq('track', 'PageView');
17+
`}
18+
</Script>
19+
<noscript>
20+
<img
21+
height="1"
22+
width="1"
23+
style={{ display: 'none' }}
24+
src={`https://www.facebook.com/tr?id=${process.env.NEXT_PUBLIC_PIXEL_ID}&ev=PageView&noscript=1`}
25+
/>
26+
</noscript>
27+
</>
28+
);
29+
30+
export default FacebookPixel;

apps/website/src/components/GoogleAnalytics/index.tsx renamed to apps/website/src/components/Metrics/GoogleAnalytics/index.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Script from 'next/script';
2-
import React from 'react';
32

4-
const GoogleAnalytics = () => (
3+
export const GoogleAnalytics = () => (
54
<>
65
<Script
76
strategy="lazyOnload"
@@ -20,5 +19,3 @@ const GoogleAnalytics = () => (
2019
</Script>
2120
</>
2221
);
23-
24-
export default GoogleAnalytics;

apps/website/src/providers/AppProviders.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import GoogleAnalytics from '@components/GoogleAnalytics';
1+
import { FacebookPixel } from '@components/Metrics/FacebookPixel';
2+
import { GoogleAnalytics } from '@components/Metrics/GoogleAnalytics';
23
import { ServiceWorkerSubscriber } from '@components/ServiceWorker/ServiceWorkerSubscriber';
34
import { Toaster } from '@intlayer/design-system';
45
import { AsyncStateProvider } from '@intlayer/design-system/hooks';
@@ -18,6 +19,7 @@ export const AppProviders: FC<AppProvidersProps> = ({ children, locale }) => (
1819
<AsyncStateProvider>
1920
<Toaster />
2021
<GoogleAnalytics />
22+
<FacebookPixel />
2123
{children}
2224
</AsyncStateProvider>
2325
</AnimatePresenceProvider>

0 commit comments

Comments
 (0)