Skip to content

Commit ca26899

Browse files
committed
Add Twitter pixel tracking and enhance TrackedButton for event tracking
- Integrated Twitter pixel script into the layout component to enable tracking of user interactions. - Updated TrackedButton component to include tracking for signup and demo events using the Twitter pixel. - Removed the Simple Analytics script to streamline analytics integration.
1 parent 9d99b1e commit ca26899

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

docs-v2/src/app/layout.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
9696
__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');`,
9797
}}
9898
/>
99+
<Script
100+
id="twitter-pixel"
101+
strategy="afterInteractive"
102+
dangerouslySetInnerHTML={{
103+
__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);
104+
},s.version='1.1',s.queue=[],u=t.createElement(n),u.async=!0,u.src='https://static.ads-twitter.com/uwt.js',
105+
a=t.getElementsByTagName(n)[0],a.parentNode.insertBefore(u,a))}(window,document,'script');
106+
twq('config','qj0po');`,
107+
}}
108+
/>
99109
</head>
100110
<Script
101111
src="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=
109119
"data-api-key": process.env.NEXT_PUBLIC_RYBBIT_API_KEY,
110120
})}
111121
/>
112-
<Script src="https://scripts.simpleanalyticscdn.com/latest.js" strategy="afterInteractive" />
113122
<body className={`flex flex-col min-h-screen ${inter.variable} font-sans`}>
114123
<noscript>
115124
<iframe

docs-v2/src/components/TrackedButton.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface TrackedButtonProps {
1414
declare global {
1515
interface Window {
1616
dataLayer?: any[];
17+
twq?: (action: string, eventId: string, data?: any) => void;
1718
}
1819
}
1920

@@ -26,6 +27,16 @@ export function TrackedButton({ children, eventName, eventData = {}, className,
2627
});
2728
}
2829

30+
// Track X/Twitter lead event for signup-related buttons
31+
if (typeof window !== "undefined" && window.twq) {
32+
if (["signup"].some(event => eventName.toLowerCase().includes(event))) {
33+
window.twq("event", "tw-qj0po-qjdz6", {});
34+
}
35+
if (["demo"].some(event => eventName.toLowerCase().includes(event))) {
36+
window.twq("event", "tw-qj0po-qje0f", {});
37+
}
38+
}
39+
2940
if (onClick) {
3041
onClick();
3142
}

0 commit comments

Comments
 (0)