Google埋点实现
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-DQHBQT85CC"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
// 设置用户ID(假设固定为A001)
gtag('set', { 'user_id': 'A001' });
// 配置GA属性,启用用户ID跟踪
gtag('config', 'G-DQHBQT85CC', {
'send_page_view': true, // 发送页面查看事件
'user_id': 'A001' // 在配置中包含用户ID
});
</script>
</head>
<body>
333
</body>
</html>
埋点效果:

记得收藏并关注,掌握更多相关知识!!!

浙公网安备 33010602011771号