I recently started using Google Analytics and I am looking to integrate it into a website that I'm currently building.
Current scenario
Initially, I added the Google Analytics tracking code to my index.ejs file. Here is how the code looks:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-162300254-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-162300254-1');
</script>
<title><%- htmlWebpackPlugin.options.metadata.title %></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="favicon.ico">
<base href="<%- htmlWebpackPlugin.options.metadata.baseUrl %>">
<!-- imported CSS are concatenated and added automatically -->
</head>
<body aurelia-app="main">
<% if (htmlWebpackPlugin.options.metadata.server) { %>
<!-- Webpack Dev Server reload -->
<script src="/webpack-dev-server.js"></script>
<% } %>
</body>
</html>
I inserted the code provided by Google Analytics into this file as instructed.
After testing my website locally, I could see one active user but was unable to track which pages were being visited frequently. The "Active pages" tab only displayed "/" as the active page.
The issue
Upon further examination, I realized that I may have missed a crucial step during the setup process, resulting in a lack of valuable insights from the data collected by Google Analytics.
If there are any uncertainties or recommendations, please feel free to share them with me.
Thank you.