Skip to content

Commit

Permalink
Merge pull request #48 from Kolossi/master
Browse files Browse the repository at this point in the history
Add Google Analytics GA4 code (Issue #45)
  • Loading branch information
amitmerchant1990 authored Feb 16, 2021
2 parents 345ea0e + 6c49168 commit c6edc6d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ disqus:
# Enter your Google Analytics web tracking code (e.g. UA-2110908-2) to activate tracking
google_analytics: UA-43339302-11

# For newer "GA4" analytics, use the following instead of the "UA" entry above
#google_analytics_ga4: G-GABC1DEFG

# Your website URL (e.g. http://amitmerchant1990.github.io or http://www.amitmerchant.com)
# Used for Sitemap.xml and your RSS feed
url: http://www.amitmerchant.com/reverie
Expand Down
9 changes: 9 additions & 0 deletions _includes/analytics_head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% if site.google_analytics_ga4 %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics_ga4 }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ site.google_analytics_ga4 }}');
</script>
{% endif %}
1 change: 1 addition & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<meta name="theme-color" content="#000000">
<link rel="icon" type="image/png" sizes="32x32" href="{{ site.baseurl }}/images/favicon-32x32.png">
{% include analytics_head.html %}
</head>

<body>
Expand Down

0 comments on commit c6edc6d

Please sign in to comment.