🚀 Tracker.js 快速集成
最小化集成代码示例
⚠️ 重要: 将 https://your-kalocash-domain.com 替换为您的实际 KaloCash 服务器地址
步骤 1: 引入脚本
<script src="https://your-kalocash-domain.com/static/web/js/tracker.js"></script>
步骤 2: 初始化
<script>
document.addEventListener('DOMContentLoaded', function() {
if (typeof GA4Tracker !== 'undefined') {
GA4Tracker.init({
apiBaseUrl: 'https://your-kalocash-domain.com', // ⚠️ 必须配置
autoPageView: true,
debug: false
});
}
});
</script>
完整示例
<!DOCTYPE html>
<html>
<head>
<title>我的网站</title>
<script src="https://your-kalocash-domain.com/static/web/js/tracker.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
if (typeof GA4Tracker !== 'undefined') {
GA4Tracker.init({
apiBaseUrl: 'https://your-kalocash-domain.com',
autoPageView: true,
debug: false
});
}
});
</script>
</head>
<body>
<h1>欢迎访问</h1>
<!-- 您的网站内容 -->
</body>
</html>
自定义事件跟踪
<button onclick="GA4Tracker.trackEvent('button_click', {button_name: '提交按钮'})">
点击我
</button>
💡 提示: 更多详细文档请查看 tracker-integration-example.html