Skip to content

Commit a908b15

Browse files
feat: added pixel (#1108)
2 parents 1ee8c41 + d1620d6 commit a908b15

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"use client";
2+
3+
import Script from "next/script";
4+
import React from "react";
5+
6+
export default function FacebookPixel() {
7+
return (
8+
<>
9+
{/* Facebook Pixel Script */}
10+
<Script id="facebook-pixel" strategy="afterInteractive">
11+
{`
12+
!function(f,b,e,v,n,t,s)
13+
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
14+
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
15+
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
16+
n.queue=[];t=b.createElement(e);t.async=!0;
17+
t.src=v;s=b.getElementsByTagName(e)[0];
18+
s.parentNode.insertBefore(t,s)}(window, document,'script',
19+
'https://connect.facebook.net/en_US/fbevents.js');
20+
fbq('init', '1793133881311033');
21+
fbq('track', 'PageView');
22+
`}
23+
</Script>
24+
25+
{/* NoScript fallback */}
26+
<noscript>
27+
<img
28+
height="1"
29+
width="1"
30+
style={{ display: "none" }}
31+
src="https://www.facebook.com/tr?id=1793133881311033&ev=PageView&noscript=1"
32+
alt="fb pixel"
33+
/>
34+
</noscript>
35+
</>
36+
);
37+
}

apps/landing/components/Layout/Layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Sidebar from "@/components/Layout/Sidebar";
77
import Footer from "@/components/Layout/Footer";
88
import clarity, { getCustomeId, sessionId } from "@/lib/clarity";
99
import { usePathname } from "next/navigation";
10+
import FacebookPixel from "@/components/Layout/FacebookPixel";
1011

1112
const Layout: React.FC<{ children: React.ReactNode }> = ({ children }) => {
1213
const [showSidebar, setShowSidebar] = useState(false);
@@ -23,6 +24,7 @@ const Layout: React.FC<{ children: React.ReactNode }> = ({ children }) => {
2324
showSidebar,
2425
})}
2526
>
27+
<FacebookPixel />
2628
<Navbar toggleSidebar={() => setShowSidebar((prev) => !prev)} />
2729
{showSidebar ? <Sidebar hide={() => setShowSidebar(false)} /> : null}
2830
{children}

0 commit comments

Comments
 (0)