Skip to content

Commit

Permalink
Support Google Analytics GA4 (#101)
Browse files Browse the repository at this point in the history
* Support Google Analytics GA4

* Update header.html

---------

Co-authored-by: Ram <2862724+rampatra@users.noreply.github.com>
  • Loading branch information
mobeigi and rampatra authored Aug 18, 2024
1 parent d66417f commit 676eb0e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
<link rel="stylesheet" href="assets/css/ie9.css"/><![endif]-->
<!--[if lte IE 8]>
<link rel="stylesheet" href="assets/css/ie8.css"/><![endif]-->
<!-- Google Analytics -->
{% if site.google_analytics %}
<!-- Google Analytics (GA4) -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ site.google_analytics }}');
</script>
{% endif %}
{% endif %}

0 comments on commit 676eb0e

Please sign in to comment.