-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathga4native.html
52 lines (45 loc) · 1.38 KB
/
ga4native.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html>
<head>
<title>Google Tag Tester</title>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-7CNRX4XR6V"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-7CNRX4XR6V', {
'content_group': '/news/sports'
});
</script>
</head>
<body>
<h1>Google Tag Tester</h1>
<p>Use the buttons below to test Google Analytics events and configurations.</p>
<!-- New Buttons -->
<button onclick="loginUser()">Login User</button>
<button onclick="triggerTestEvent1()">Trigger Test Event 1</button>
<button onclick="logoutUser()">Logout User</button>
<button onclick="triggerTestEvent2()">Trigger Test Event 2</button>
<script type="text/javascript">
function loginUser() {
gtag('config', 'G-7CNRX4XR6V', {
'user_id': 'UserID123'
});
}
function triggerTestEvent1() {
gtag('event', 'Test Event');
}
function logoutUser() {
gtag('config', 'G-7CNRX4XR6V', {
'user_id': 'null'
});
}
function triggerTestEvent2() {
gtag('event', 'Test Event 2');
}
</script>
</body>
</html>