fix: include URL in outbound/download events, exclude form inputs from dead clicks

This commit is contained in:
Usman Baig
2026-03-13 09:11:23 +01:00
parent 6e213539ea
commit f7340fa763
2 changed files with 8 additions and 2 deletions

View File

@@ -19,6 +19,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
- **UTM attribution now works correctly.** Visitors arriving via campaign links (e.g. from Facebook Ads, Google Ads, or email campaigns) now have their traffic source, medium, and campaign properly recorded. Previously, this data was accidentally lost before it reached the server.
- **More ad tracking clutter removed from page paths.** Facebook ad parameters and click IDs from various platforms are cleaned from your page URLs so your Top Pages stay tidy.
- **Better bot detection.** Automated browsers (used by scrapers and testing tools) and bots with no screen dimensions are now filtered out before they can send events, keeping your visitor counts cleaner.
- **Outbound links and file downloads now show the URL.** Previously you could only see how many outbound clicks or downloads happened. Now you can see exactly which external links visitors clicked and which files they downloaded.
- **Dead click detection no longer triggers on form fields.** Clicking on a text input, dropdown, or text area to interact with it is normal — it no longer gets flagged as a dead click.
## [0.15.0-alpha] - 2026-03-13

View File

@@ -699,6 +699,10 @@
var target = findInteractiveElement(e.target);
if (!target) return;
// * Skip form inputs — clicking to focus/interact is expected, not a dead click
var tag = target.tagName;
if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') return;
var selector = getElementIdentifier(target);
if (!selector) return;
@@ -796,13 +800,13 @@
// * Check file download first (download attribute or known file extension)
if (trackDownloads && (el.hasAttribute('download') || FILE_EXT_REGEX.test(url.pathname))) {
trackCustomEvent('file_download');
trackCustomEvent('file_download', { url: url.href });
return;
}
// * Check outbound link (different hostname)
if (trackOutbound && url.hostname && url.hostname !== location.hostname) {
trackCustomEvent('outbound_link');
trackCustomEvent('outbound_link', { url: url.href });
}
} catch (err) {
// * Invalid URL - skip silently