Skip to content

Commit

Permalink
Add Google Analytics 4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ipasechnikov committed Feb 4, 2023
1 parent 9011f75 commit 7cbfbc0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions _includes/google_analytics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- Google tag (gtag.js) -->
<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>
4 changes: 4 additions & 0 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

{%-seo title=false-%}
{%-feed_meta-%}

{%- if jekyll.environment == 'production' and site.google_analytics -%}
{%- include google_analytics.html -%}
{%- endif -%}

<link rel="shortcut icon" type="image/x-icon" href="{{ site.favicon | relative_url }}" />
<link rel="stylesheet" href="{{ "/assets/css/main.css" | relative_url }}" />
Expand Down

0 comments on commit 7cbfbc0

Please sign in to comment.