-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathga4.html
100 lines (92 loc) · 2.76 KB
/
ga4.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Apple-like Product Page with GA4 Integration</title>
<style>
/* Style the layout */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
header {
background-color: #333;
color: white;
text-align: center;
padding: 1rem;
}
.container {
max-width: 800px;
margin: auto;
padding: 1rem;
}
.product-info {
background-color: white;
padding: 2rem;
margin: 1rem 0;
border-radius: 12px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
}
form {
margin-top: 1rem;
}
label, input, button {
display: block;
width: 100%;
margin-bottom: 1rem;
padding: 0.5rem;
}
button {
background-color: #007BFF;
color: white;
border: none;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
</style>
<!-- GA4 Placeholder: Add your GA4 Snippet here -->
<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');
function sendFormSubmitEvent() {
gtag('event', 'form_submit', {
'event_category': 'form',
'event_label': 'Form Submitted'
});
}
function sendButtonClickEvent() {
gtag('event', 'button_click', {
'event_category': 'button',
'event_label': 'Button Clicked'
});
}
</script>
</head>
<body>
<header>
<h1>Our Amazing Tracking</h1>
</header>
<div class="container">
<div class="product-info">
<h2>Tracking Details</h2>
<!-- Form to send events to GA4 -->
<form onsubmit="sendFormSubmitEvent();">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<button type="submit">Submit</button>
</form>
<!-- Button to send an event to GA4 -->
<button onclick="sendButtonClickEvent();">Learn More</button>
</div>
</div>
</body>
</html>