Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example/facebook pixel script #34417

Merged
merged 11 commits into from
May 13, 2022
1 change: 1 addition & 0 deletions examples/with-facebook-pixel/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function MyApp({ Component, pageProps }) {
<>
{/* Global Site Code Pixel - Facebook Pixel */}
<Script
id="fb-pixel"
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `
Expand Down
8 changes: 8 additions & 0 deletions examples/with-facebook-pixel/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Link from 'next/link'
import * as fbq from '../lib/fpixel'

export default function Home() {
Expand All @@ -14,6 +15,13 @@ export default function Home() {
<button type="button" onClick={handleClick}>
Buy $10
</button>
<p>
Click the link below to navigate to another page.
<br />
<Link href="/navigation">
<a>Navigation page</a>
</Link>
</p>
</div>
)
}
15 changes: 15 additions & 0 deletions examples/with-facebook-pixel/pages/navigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Link from 'next/link'

export default function NavigationPage() {
return (
<div>
<p>
Navigating between pages will trigger a pageview event in Facebook
Pixel, but will not reinitialize the pixel.
</p>
<Link href="/">
<a>Return to home</a>
</Link>
</div>
)
}