Updated scripts for correctly using gtag. (#2962)

Implementation of Google tag ID to correctly getting tracked requires
further modification in addition to the one line script in the
`_includes/scripts.liquid` file as
```
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
  <script>
    window.dataLayer = window.dataLayer || [];
    function gtag() {
      dataLayer.push(arguments);
    }
    gtag('js', new Date());

    gtag('config', '{{ site.google_analytics }}');
  </script>
```

I have made the changes and tested it out on my personal webpage to
ensure the tracking in analytics dashboard.
This commit is contained in:
Soumyaranjan Dash 2025-02-09 04:41:20 -10:00 committed by GitHub
parent caf9976175
commit beeff21ecd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -216,6 +216,15 @@
<!-- Analytics --> <!-- Analytics -->
<!-- Global site tag (gtag.js) - Google Analytics --> <!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script> <script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', '{{ site.google_analytics }}');
</script>
<script defer src="{{ '/assets/js/google-analytics-setup.js' | relative_url | bust_file_cache }}"></script> <script defer src="{{ '/assets/js/google-analytics-setup.js' | relative_url | bust_file_cache }}"></script>
{% endif %} {% endif %}