From 27612cecd3b9d56ce7ed6d70f135b2a8576f37b9 Mon Sep 17 00:00:00 2001 From: shigahi Date: Thu, 22 Jan 2026 23:44:35 +0100 Subject: [PATCH] Add Facebook Pixel tracking support - Add facebookPixelId to AnalyticsOptions interface - Add Facebook Pixel script injection in HeadRewriter - Add Facebook Pixel ID input field in Analytics section Closes #31 --- src/App.tsx | 14 ++++++++++++++ src/code.ts | 23 ++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index 6437c31..63999b5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -161,6 +161,7 @@ export default function App() { >({}); const [analytics, setAnalytics] = useState({ googleTagId: "", + facebookPixelId: "", }); const [customHtml, setCustomHtml] = useState({ headerHtml: "", @@ -928,6 +929,19 @@ export default function App() { variant="outlined" size="small" /> + + handleAnalyticsChange("facebookPixelId", e.target.value) + } + value={analytics.facebookPixelId} + variant="outlined" + size="small" + /> diff --git a/src/code.ts b/src/code.ts index 921232b..7b1f830 100644 --- a/src/code.ts +++ b/src/code.ts @@ -36,6 +36,7 @@ export interface SeoOptions { export interface AnalyticsOptions { googleTagId?: string; + facebookPixelId?: string; } export interface CustomHtmlOptions { @@ -160,9 +161,10 @@ ${slugs /* * Step 3.5: analytics configuration (optional) - * Add your Google Analytics 4 Measurement ID for built-in tracking + * Add your Google Analytics 4 Measurement ID and/or Facebook Pixel ID for built-in tracking */ const GOOGLE_TAG_ID = '${analytics?.googleTagId || ""}'; + const FACEBOOK_PIXEL_ID = '${analytics?.facebookPixelId || ""}'; /* * Step 3.6: custom HTML header injection (optional) @@ -565,6 +567,25 @@ ${ \`, { html: true }); } + // Add Facebook Pixel if configured (Issue #31) + if (FACEBOOK_PIXEL_ID !== '') { + element.append(\` + \`, { html: true }); + } + // Add Twitter/X meta tags for social cards (Issue #19) if (TWITTER_HANDLE !== '') { element.append(\`\`, { html: true });