Skip to content

Commit

Permalink
Updated scripts for correctly using gtag. (#2962)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sr-dash authored Feb 9, 2025
1 parent caf9976 commit beeff21
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions _includes/scripts.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@
<!-- Analytics -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<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>
{% endif %}

Expand Down

0 comments on commit beeff21

Please sign in to comment.