Count a hanzo.chat visit once, not twice

A first visit loads / and then round-trips through the issuer's silent
sign-in to /auth/callback, a second document that sent a second
page_view for the same visit.  The callback no longer sends one; GA4's
history listener still counts the routes that follow.
This commit is contained in:
2026-09-28 10:43:41 -07:00
parent 71eb7b98e5
commit 2898607b0b
+8 -3
View File
@@ -25,15 +25,20 @@
brand, so a host with no stream here sends nothing. The first page view brand, so a host with no stream here sends nothing. The first page view
queues before the bundle; gtag.js is fetched after `load`, since a script queues before the bundle; gtag.js is fetched after `load`, since a script
in the head holds the load event until its host answers. Route changes in the head holds the load event until its host answers. Route changes
are GA4's own history listener. Global Privacy Control and Do Not Track are GA4's own history listener. /auth/callback sends no page view of
opt out. --> its own: a first visit round-trips there through the issuer's silent
sign-in, and the visit has already been counted. Global Privacy Control
and Do Not Track opt out. -->
<script> <script>
var tid = { 'hanzo.chat': 'G-GRQBMNDTT6' }[location.hostname]; var tid = { 'hanzo.chat': 'G-GRQBMNDTT6' }[location.hostname];
if (tid && !navigator.globalPrivacyControl && navigator.doNotTrack !== '1') { if (tid && !navigator.globalPrivacyControl && navigator.doNotTrack !== '1') {
window.dataLayer = window.dataLayer || []; window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)} function gtag(){dataLayer.push(arguments)}
gtag('js', new Date()); gtag('js', new Date());
gtag('config', tid, { linker: { domains: [location.hostname, 'hanzo.ai', 'hanzo.id', 'pay.hanzo.ai', 'cal.hanzo.ai'] } }); gtag('config', tid, {
send_page_view: location.pathname !== '/auth/callback',
linker: { domains: [location.hostname, 'hanzo.ai', 'hanzo.id', 'pay.hanzo.ai', 'cal.hanzo.ai'] },
});
addEventListener('load', function () { addEventListener('load', function () {
var s = document.createElement('script'); var s = document.createElement('script');
s.async = true; s.async = true;