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

feat: Introduce AnalyticsLinkButton for Google Analytics conversion tracking #1469

Merged
merged 1 commit into from
Jan 31, 2025

Conversation

siamak
Copy link
Collaborator

@siamak siamak commented Jan 30, 2025

This PR introduces the AnalyticsLinkButton component, a wrapper around LinkButton that adds Google Analytics conversion tracking (gtag_report_conversion) before navigation. This ensures that conversion tracking fires correctly when users click external links.

Changes:
• Created AnalyticsLinkButton.tsx as a Client Component.
• Uses onMouseDown to trigger gtag_report_conversion(href) before link navigation.
• Handles potential SSR issues by checking for window.
• Improved performance with useCallback to prevent unnecessary re-renders.

Copy link

vercel bot commented Jan 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
codemod ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 30, 2025 7:47pm

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

pkg-pr-new bot commented Jan 30, 2025

Open in Stackblitz

npm i https://pkg.pr.new/codemod@1469

commit: 6f2e03e

@mohab-sameh mohab-sameh merged commit ca7fe2b into main Jan 31, 2025
11 of 12 checks passed
@mohab-sameh mohab-sameh deleted the feature/conversion-tracking branch January 31, 2025 10:42
mohab-sameh added a commit that referenced this pull request Jan 31, 2025
mohab-sameh added a commit that referenced this pull request Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants