Skip to content

Commit

Permalink
Merge pull request #22 from Qompa-Fi/FacebookPixel
Browse files Browse the repository at this point in the history
feat: 📈 Facebook Pixel
  • Loading branch information
espinozasenior authored Nov 14, 2024
2 parents 5331cd5 + ba5ae00 commit d99a54b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/common/Analytics.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
import { GoogleAnalytics } from '@astrolib/analytics';
import FacebookPixel from '../common/FacebookPixel.astro';
import { ANALYTICS } from 'astrowind:config';
---

Expand All @@ -11,3 +12,11 @@ import { ANALYTICS } from 'astrowind:config';
/>
) : null
}

{
ANALYTICS?.vendors?.googleAnalytics?.id ? (
<FacebookPixel
id={String(ANALYTICS.vendors.facebookPixel.id)}
/>
) : null
}
30 changes: 30 additions & 0 deletions src/components/common/FacebookPixel.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
// import ShowIf from './ShowIf.astro';
export interface Props {
id: string;
partytown?: boolean;
}
const { id = "" } = Astro.props;
---

{/* <ShowIf id={id}> */}
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=818276990270615&ev=PageView&noscript=1"
/></noscript>
<script is:inline async src={`https://connect.facebook.net/en_US/fbevents.js`}></script>

<script is:inline define:vars={{ id }}>
window.dataLayer = window.dataLayer || [];
function fbq() {
window.dataLayer.push(arguments);
}
fbq("init", "818276990270615");
fbq("track", "PageView");
</script>
{/* </ShowIf> */}


<!-- Meta Pixel Code -->
2 changes: 2 additions & 0 deletions src/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ analytics:
vendors:
googleAnalytics:
id: 'G-KL3CGBG84Q' # or "G-XXXXXXXXXX"
facebookPixel:
id: '818276990270615'

ui:
theme: 'dark:only' # Values: "system" | "light" | "dark" | "light:only" | "dark:only"

0 comments on commit d99a54b

Please sign in to comment.