Skip to content

Commit

Permalink
Merge pull request #20 from skipgu/manual-include-analytics
Browse files Browse the repository at this point in the history
added google analytics from config to analytics script, added script …
  • Loading branch information
michalspano authored Nov 15, 2023
2 parents 59f0466 + 90eabc8 commit f44bd11
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ email: skip@gota.gu.se
instagram_username: "skip.gu"
linkedin_username: "company/skip-student-association"
discord_link: "https://tinyurl.com/skip-discord"
# google_analytics: G-96M5M9TCM7
google_analytics: G-96M5M9TCM7
10 changes: 4 additions & 6 deletions _includes/google-analytics.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-96M5M9TCM7"></script>
<!-- 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());
// The value is parsed 'raw' like this, because it's part of the URL above anyway.
// Therefore, the value from _config.yml need not to be used.
gtag('config', 'G-96M5M9TCM7');
</script>

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 @@ -43,4 +43,8 @@
{% endcomment %}
{% include head-feed.html %}
{% endif %}

{% if jekyll.environment == 'production' and site.google_analytics %}
{% include google-analytics.html %}
{% endif %}
</head>

0 comments on commit f44bd11

Please sign in to comment.