Google Analytics in Jekyll
This post contains step by step guide to setup google analytics for your Jekyll powered page. The only requirements are google account and working Jekyll powered page.
-
log into analytics with your google account
-
setup analytics account and property in my case github.io and sansajn.github.io as property
-
setup Data Stream for sansajn.github.io property from previous step
-
copy Global Site Tag, in my case
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-88ZTXK100S"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-89ZTXX100S');
</script>
note: your measurement id (in my case G-89ZTXX100S) will differ so do not just copy paste from there
-
create
google-analytics.html
in_includes
and paste GST (Global Site Tag) from previous step and save -
copy
default.html
from/var/lib/gems/2.7.0/gems/minima-2.5.1/_layouts/
to_layouts
in your Jekyll project
note: in Ubuntu 20.04 LTS default minima theme is stored in /var/lib/gems/2.7.0/gems/minima-2.5.1 directory
- open copied
default.html
and insert
line just after include head.html
liquid statement between opening <html>
and <body>
HTML elements, this way
and you are done!