fix(analytics): 更新Google Analytics配置和变量命名

更新环境变量命名以匹配GA4标准,并调整默认存储权限配置
添加页面浏览跟踪逻辑,当用户同意分析时发送页面数据
This commit is contained in:
张翔
2026-05-02 08:27:38 +08:00
parent 57e242c5c6
commit f0657ce9f4
3 changed files with 18 additions and 8 deletions
+8
View File
@@ -174,6 +174,14 @@ export const updateConsentDetailed = (preferences: CookiePreferences) => {
personalization_storage: preferences.marketing ? 'granted' : 'denied',
security_storage: 'granted',
});
if (preferences.analytics) {
window.gtag('config', GA_MEASUREMENT_ID, {
page_path: window.location.pathname + window.location.search,
page_title: document.title,
page_location: window.location.href,
});
}
}
};