We use Scarf to measure page views and actions on the Site, - including external link clicks, downloads, and copy and paste. For - copy and paste events, we send the first 512 characters of plain - text along with the page path. This text may include information you - choose to copy or paste. We do not collect text from password fields - for these events. + including external link clicks, hover intent, downloads, and copy + and paste. For copy and paste events, we send the first 512 + characters of plain text along with the page path. This text may + include information you choose to copy or paste. We do not collect + text from password fields for these events.
We use namethathost.com, operated by TanStack, to understand which
diff --git a/src/utils/analytics/scarf.ts b/src/utils/analytics/scarf.ts
index e68447b44..ad87346cf 100644
--- a/src/utils/analytics/scarf.ts
+++ b/src/utils/analytics/scarf.ts
@@ -36,7 +36,9 @@ export const scarfAnalyticsProvider: AnalyticsProvider = {
action: String(properties.action),
surface: String(properties.surface),
automatic: String(properties.automatic),
- ...(properties.provider ? { provider: String(properties.provider) } : {}),
+ ...(properties.provider
+ ? { provider: String(properties.provider) }
+ : {}),
})
} else if (event === 'partner_inquiry_started') {
sendScarfEvent(event, {
@@ -121,6 +123,18 @@ export function trackScarfDownloadClick(event: MouseEvent) {
sendScarfEvent('download_requested', { page: window.location.pathname })
}
+function getExternalLinkDestination(link: HTMLAnchorElement) {
+ const destination = new URL(link.href, window.location.href)
+ if (
+ !['http:', 'https:'].includes(destination.protocol) ||
+ destination.origin === window.location.origin
+ ) {
+ return null
+ }
+
+ return `${destination.origin}${destination.pathname}`
+}
+
export function trackScarfExternalLinkClick(event: MouseEvent) {
const target = event.target
if (!(target instanceof Element)) return
@@ -128,16 +142,86 @@ export function trackScarfExternalLinkClick(event: MouseEvent) {
const link = target.closest('a[href]')
if (!(link instanceof HTMLAnchorElement)) return
- const destination = new URL(link.href, window.location.href)
- if (
- !['http:', 'https:'].includes(destination.protocol) ||
- destination.origin === window.location.origin
- ) {
- return
- }
+ const destination = getExternalLinkDestination(link)
+ if (!destination) return
sendScarfEvent('external_link_click', {
page: window.location.pathname,
- destination: `${destination.origin}${destination.pathname}`,
+ destination,
})
}
+
+export function trackScarfExternalLinkHoverIntent() {
+ let hoveredLink: HTMLAnchorElement | null = null
+ let timer: ReturnType