mirror of
https://github.com/hanzoai/chat.git
synced 2026-09-30 20:51:17 +00:00
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:
+8
-3
@@ -25,15 +25,20 @@
|
||||
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
|
||||
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
|
||||
opt out. -->
|
||||
are GA4's own history listener. /auth/callback sends no page view of
|
||||
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>
|
||||
var tid = { 'hanzo.chat': 'G-GRQBMNDTT6' }[location.hostname];
|
||||
if (tid && !navigator.globalPrivacyControl && navigator.doNotTrack !== '1') {
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments)}
|
||||
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 () {
|
||||
var s = document.createElement('script');
|
||||
s.async = true;
|
||||
|
||||
Reference in New Issue
Block a user