Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions apps/web-roo-code/src/app/pr-fixer/PrFixerContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ export function PrFixerContent() {
href={EXTERNAL_LINKS.CLOUD_APP_SIGNUP_PRO}
target="_blank"
rel="noopener noreferrer"
onClick={trackGoogleAdsConversion}
onClick={(e) => {
e.preventDefault()
trackGoogleAdsConversion(EXTERNAL_LINKS.CLOUD_APP_SIGNUP_PRO)
}}
Comment on lines +115 to +118
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue: this changes the link behavior from opening in a new tab to navigating the current tab. The anchor has target="_blank" but e.preventDefault() + window.location.href overrides this. Use window.open(targetUrl, '_blank') to preserve the new tab behavior.

Fix it with Roo Code or mention @roomote and request a fix.

className="flex w-full items-center justify-center">
Start 14-day Free Trial
<ArrowRight className="ml-2" />
Expand Down Expand Up @@ -225,7 +228,10 @@ export function PrFixerContent() {
href={EXTERNAL_LINKS.CLOUD_APP_SIGNUP_PRO}
target="_blank"
rel="noopener noreferrer"
onClick={trackGoogleAdsConversion}
onClick={(e) => {
e.preventDefault()
trackGoogleAdsConversion(EXTERNAL_LINKS.CLOUD_APP_SIGNUP_PRO)
}}
Comment on lines +231 to +234
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue: this changes the link behavior from opening in a new tab to navigating the current tab. The anchor has target="_blank" but e.preventDefault() + window.location.href overrides this. Use window.open(targetUrl, '_blank') to preserve the new tab behavior.

Fix it with Roo Code or mention @roomote and request a fix.

className="flex items-center justify-center">
Start 14-day Free Trial
<ArrowRight className="ml-2 h-4 w-4" />
Expand Down
10 changes: 8 additions & 2 deletions apps/web-roo-code/src/app/reviewer/ReviewerContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ export function ReviewerContent() {
href={EXTERNAL_LINKS.CLOUD_APP_SIGNUP_PRO}
target="_blank"
rel="noopener noreferrer"
onClick={trackGoogleAdsConversion}
onClick={(e) => {
e.preventDefault()
trackGoogleAdsConversion(EXTERNAL_LINKS.CLOUD_APP_SIGNUP_PRO)
}}
Comment on lines +130 to +133
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the link behavior from opening in a new tab to navigating the current tab. The anchor has target="_blank" but e.preventDefault() + window.location.href overrides this, breaking the original user experience of keeping the marketing site open while opening the signup page in a new tab. Use window.open(targetUrl, '_blank') to preserve the new tab behavior.

Fix it with Roo Code or mention @roomote and request a fix.

className="flex w-full items-center justify-center">
Start 14-day Free Trial
<ArrowRight className="ml-2" />
Expand Down Expand Up @@ -281,7 +284,10 @@ export function ReviewerContent() {
href={EXTERNAL_LINKS.CLOUD_APP_SIGNUP_PRO}
target="_blank"
rel="noopener noreferrer"
onClick={trackGoogleAdsConversion}
onClick={(e) => {
e.preventDefault()
trackGoogleAdsConversion(EXTERNAL_LINKS.CLOUD_APP_SIGNUP_PRO)
}}
Comment on lines +287 to +290
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue: this changes the link behavior from opening in a new tab to navigating the current tab. The anchor has target="_blank" but e.preventDefault() + window.location.href overrides this. Use window.open(targetUrl, '_blank') to preserve the new tab behavior.

Fix it with Roo Code or mention @roomote and request a fix.

className="flex items-center justify-center">
Start 14-day Free Trial
<ArrowRight className="ml-2 h-4 w-4" />
Expand Down
31 changes: 28 additions & 3 deletions apps/web-roo-code/src/lib/analytics/google-ads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,40 @@
*/

/**
* Track a Google Ads conversion event
* This should only be called after user consent has been given
* Track a Google Ads conversion event with optional navigation callback
* This ensures the conversion ping completes before navigation occurs
*
* @param targetUrl - Optional URL to navigate to after conversion is tracked
*
* @example
* // Track conversion and navigate
* trackGoogleAdsConversion("https://app.roocode.com")
*
* @example
* // Track conversion without navigation
* trackGoogleAdsConversion()
*/
export function trackGoogleAdsConversion() {
export function trackGoogleAdsConversion(targetUrl?: string) {
if (typeof window !== "undefined" && window.gtag) {
// Callback to handle navigation after conversion tracking
const callback = () => {
if (targetUrl) {
window.location.href = targetUrl
}
}

window.gtag("event", "conversion", {
send_to: "AW-17391954825/VtOZCJe_77MbEInXkOVA",
value: 10.0,
currency: "USD",
event_callback: callback,
})

// Fallback timeout in case event_callback doesn't fire (network issues, etc.)
// This ensures navigation still happens even if tracking fails
setTimeout(callback, 1000)
} else if (targetUrl) {
// If gtag is not available, navigate immediately
window.location.href = targetUrl
}
}
Comment on lines +19 to 42
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The callback can execute twice: once from event_callback and once from setTimeout. If the tracking completes before 1 second (the common case), both navigation attempts will fire. This should use a flag to ensure the callback only executes once.

Suggested change
export function trackGoogleAdsConversion(targetUrl?: string) {
if (typeof window !== "undefined" && window.gtag) {
// Callback to handle navigation after conversion tracking
const callback = () => {
if (targetUrl) {
window.location.href = targetUrl
}
}
window.gtag("event", "conversion", {
send_to: "AW-17391954825/VtOZCJe_77MbEInXkOVA",
value: 10.0,
currency: "USD",
event_callback: callback,
})
// Fallback timeout in case event_callback doesn't fire (network issues, etc.)
// This ensures navigation still happens even if tracking fails
setTimeout(callback, 1000)
} else if (targetUrl) {
// If gtag is not available, navigate immediately
window.location.href = targetUrl
}
}
export function trackGoogleAdsConversion(targetUrl?: string) {
if (typeof window !== "undefined" && window.gtag) {
let hasNavigated = false
// Callback to handle navigation after conversion tracking
const callback = () => {
if (!hasNavigated && targetUrl) {
hasNavigated = true
window.location.href = targetUrl
}
}
window.gtag("event", "conversion", {
send_to: "AW-17391954825/VtOZCJe_77MbEInXkOVA",
value: 10.0,
currency: "USD",
event_callback: callback,
})
// Fallback timeout in case event_callback doesn't fire (network issues, etc.)
// This ensures navigation still happens even if tracking fails
setTimeout(callback, 1000)
} else if (targetUrl) {
// If gtag is not available, navigate immediately
window.location.href = targetUrl
}
}

Fix it with Roo Code or mention @roomote and request a fix.