Skip to content

Commit 1cff4f8

Browse files
committed
feat: plausible integration
1 parent f080e2d commit 1cff4f8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/components/SocialShareButtons.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ export function SocialShareButtons({ title, description, url }: SocialShareButto
1111
const encodedTitle = encodeURIComponent(title);
1212
const encodedText = encodeURIComponent(`${title} - ${description}`);
1313

14+
const handleShareClick = (platform: string) => {
15+
// Track share button click with Plausible
16+
if (typeof window !== 'undefined' && (window as any).plausible) {
17+
(window as any).plausible('Share Click', { props: { platform } });
18+
}
19+
};
20+
1421
const shareLinks = [
1522
{
1623
name: 'Twitter',
@@ -61,6 +68,7 @@ export function SocialShareButtons({ title, description, url }: SocialShareButto
6168
target="_blank"
6269
rel="noopener noreferrer"
6370
aria-label={`Share on ${name}`}
71+
onClick={() => handleShareClick(name)}
6472
className={`flex items-center justify-center w-10 h-10 rounded-full border border-border bg-background text-muted-foreground transition-colors ${color} hover:border-current`}
6573
>
6674
<Icon className="w-5 h-5" />

src/layouts/Layout.astro

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ const primaryHSLDark = `${h} ${s} ${lighterL}`;
7171
<!-- Preload OG image for faster social media crawler fetching -->
7272
{image && <link rel="preload" as="image" href={image} />}
7373

74+
<!-- Privacy-friendly analytics by Plausible -->
75+
<script async src="https://plausible.io/js/pa-D-pChuIO1uVcJNWr_9MOx.js"></script>
76+
<script is:inline>
77+
window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}};
78+
plausible.init()
79+
</script>
80+
7481
<!-- Theme initialization script (must run before body renders to prevent flash) -->
7582
<script is:inline>
7683
// This script runs immediately to prevent flash of unstyled content

0 commit comments

Comments
 (0)