main.html 1017 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6. <style>
  7. button {
  8. width: 100px;
  9. height: 30px;
  10. background-color: #4CAF50;
  11. color: white;
  12. border: none;
  13. border-radius: 5px;
  14. cursor: pointer;
  15. }
  16. </style>
  17. </head>
  18. <body>
  19. 谷歌埋点Demo - js
  20. <br>
  21. <strong>埋点统计数据会有延迟,请耐心等待</strong>
  22. <button id="btn" onclick="handleClick()">点击我</button>
  23. </body>
  24. <!-- Google tag (gtag.js) -->
  25. <script async src="https://www.googletagmanager.com/gtag/js?id=G-8HEB2QHV86"></script>
  26. <script>
  27. window.dataLayer = window.dataLayer || [];
  28. function gtag(){dataLayer.push(arguments);}
  29. gtag('js', new Date());
  30. gtag('config', 'G-8HEB2QHV86');
  31. gtag('event', 'pageview', {
  32. page_path: '/',
  33. value: "js:访问页面"
  34. });
  35. function handleClick() {
  36. gtag('event', 'click', {
  37. event_category: 'test',
  38. event_label: 'click',
  39. value: 'js:点击按钮'
  40. });
  41. }
  42. </script>
  43. </html>