🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Add Twitter pixel tracking and enhance TrackedButton for event tracking
Bill Yangca2689911ce7
diff --git a/docs-v2/src/app/layout.tsx b/docs-v2/src/app/layout.tsxindex 6aca38592..bc95bfbce 100644--- a/docs-v2/src/app/layout.tsx+++ b/docs-v2/src/app/layout.tsx@@ -96,6 +96,16 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=__html: `!function(w,d){if(!w.rdt){var p=w.rdt=function(){p.sendEvent?p.sendEvent.apply(p,arguments):p.callQueue.push(arguments)};p.callQueue=[];var t=d.createElement("script");t.src="https://www.redditstatic.com/ads/pixel.js",t.async=!0;var s=d.getElementsByTagName("script")[0];s.parentNode.insertBefore(t,s)}}(window,document);rdt('init','a2_hpzt3lz1c1f0');rdt('track', 'PageVisit');`,}}/>+ <Script+ id="twitter-pixel"+ strategy="afterInteractive"+ dangerouslySetInnerHTML={{+ __html: `!function(e,t,n,s,u,a){e.twq||(s=e.twq=function(){s.exe?s.exe.apply(s,arguments):s.queue.push(arguments);+},s.version='1.1',s.queue=[],u=t.createElement(n),u.async=!0,u.src='https://static.ads-twitter.com/uwt.js',+a=t.getElementsByTagName(n)[0],a.parentNode.insertBefore(u,a))}(window,document,'script');+twq('config','qj0po');`,+ }}+ /></head><Scriptsrc="https://demo.rybbit.io/api/script.js"@@ -109,7 +119,6 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src="data-api-key": process.env.NEXT_PUBLIC_RYBBIT_API_KEY,})}/>- <Script src="https://scripts.simpleanalyticscdn.com/latest.js" strategy="afterInteractive" /><body className={`flex flex-col min-h-screen ${inter.variable} font-sans`}><noscript><iframediff --git a/docs-v2/src/components/TrackedButton.tsx b/docs-v2/src/components/TrackedButton.tsxindex bf869fd6d..ebe33f7b4 100644--- a/docs-v2/src/components/TrackedButton.tsx+++ b/docs-v2/src/components/TrackedButton.tsx@@ -14,6 +14,7 @@ interface TrackedButtonProps {declare global {interface Window {dataLayer?: any[];+ twq?: (action: string, eventId: string, data?: any) => void;}}@@ -26,6 +27,16 @@ export function TrackedButton({ children, eventName, eventData = {}, className,});}+ // Track X/Twitter lead event for signup-related buttons+ if (typeof window !== "undefined" && window.twq) {+ if (["signup"].some(event => eventName.toLowerCase().includes(event))) {+ window.twq("event", "tw-qj0po-qjdz6", {});+ }+ if (["demo"].some(event => eventName.toLowerCase().includes(event))) {+ window.twq("event", "tw-qj0po-qje0f", {});+ }+ }+if (onClick) {onClick();}