fix: screen size shadowing, popstate double pageview, custom event self-referrals
This commit is contained in:
@@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|||||||
|
|
||||||
- **More accurate pageview counts.** Refreshing a page no longer inflates your pageview numbers. The tracking script now detects when the same page is loaded again within a few seconds and skips the duplicate, so metrics like total pageviews, pages per session, and visit duration reflect real navigation instead of reload habits.
|
- **More accurate pageview counts.** Refreshing a page no longer inflates your pageview numbers. The tracking script now detects when the same page is loaded again within a few seconds and skips the duplicate, so metrics like total pageviews, pages per session, and visit duration reflect real navigation instead of reload habits.
|
||||||
- **Self-referrals no longer pollute your traffic sources.** Internal navigation within your own site (e.g. clicking from your homepage to your about page) no longer shows your own domain as a referrer. Only external traffic sources appear in your Referrers panel now.
|
- **Self-referrals no longer pollute your traffic sources.** Internal navigation within your own site (e.g. clicking from your homepage to your about page) no longer shows your own domain as a referrer. Only external traffic sources appear in your Referrers panel now.
|
||||||
|
- **Screen size fallback now works correctly.** A variable naming issue prevented the fallback screen dimensions from being read when the primary value wasn't available. Screen size data is now reliably captured on all browsers.
|
||||||
|
- **Browser back/forward no longer double-counts pageviews.** Pressing the back or forward button could occasionally register two pageviews instead of one. The tracking script now correctly deduplicates these navigations.
|
||||||
|
|
||||||
## [0.15.0-alpha] - 2026-03-13
|
## [0.15.0-alpha] - 2026-03-13
|
||||||
|
|
||||||
|
|||||||
@@ -282,16 +282,16 @@
|
|||||||
referrer = rawReferrer;
|
referrer = rawReferrer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const screen = {
|
const screenSize = {
|
||||||
width: window.innerWidth || screen.width,
|
width: window.innerWidth || window.screen.width,
|
||||||
height: window.innerHeight || screen.height,
|
height: window.innerHeight || window.screen.height,
|
||||||
};
|
};
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
domain: domain,
|
domain: domain,
|
||||||
path: path,
|
path: path,
|
||||||
referrer: referrer,
|
referrer: referrer,
|
||||||
screen: screen,
|
screen: screenSize,
|
||||||
session_id: getSessionId(),
|
session_id: getSessionId(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -354,6 +354,9 @@
|
|||||||
|
|
||||||
// * Track popstate (browser back/forward)
|
// * Track popstate (browser back/forward)
|
||||||
window.addEventListener('popstate', function() {
|
window.addEventListener('popstate', function() {
|
||||||
|
var url = location.href;
|
||||||
|
if (url === lastUrl) return;
|
||||||
|
lastUrl = url;
|
||||||
trackPageview();
|
trackPageview();
|
||||||
setTimeout(check404, 100);
|
setTimeout(check404, 100);
|
||||||
if (trackScroll) scrollFired = {};
|
if (trackScroll) scrollFired = {};
|
||||||
@@ -373,7 +376,15 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var path = window.location.pathname + window.location.search;
|
var path = window.location.pathname + window.location.search;
|
||||||
var referrer = document.referrer || '';
|
var rawRef = document.referrer || '';
|
||||||
|
var referrer = '';
|
||||||
|
if (rawRef) {
|
||||||
|
try {
|
||||||
|
var rh = new URL(rawRef).hostname.replace(/^www\./, '');
|
||||||
|
var sh = domain.replace(/^www\./, '');
|
||||||
|
if (rh !== sh) referrer = rawRef;
|
||||||
|
} catch (e) { referrer = rawRef; }
|
||||||
|
}
|
||||||
var screenSize = { width: window.innerWidth || 0, height: window.innerHeight || 0 };
|
var screenSize = { width: window.innerWidth || 0, height: window.innerHeight || 0 };
|
||||||
var payload = {
|
var payload = {
|
||||||
domain: domain,
|
domain: domain,
|
||||||
|
|||||||
Reference in New Issue
Block a user