Replies: 1 comment 1 reply
-
Hi there @Franc-Brs It's quite easy to implement Google Analytics in Forever Jekyll. Here is how you can do it, Create a file with the name google-analytics.html in _includes directory. Add the following code to it and save the file. <script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
<script>
window['ga-disable-{{ site.google_analytics }}'] = window.doNotTrack === "1" || navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1";
window.dataLayer = window.dataLayer || [];
function gtag(){window.dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ site.google_analytics }}');
</script> Next open-up the _config.yml and add,
Of-course, replace And finally, add the following code snippet to default.html in _layouts directory right below the {%- if jekyll.environment == 'production' and site.google_analytics -%}
{%- include google-analytics.html -%}
{%- endif -%} Save the file and voila! you have your Google Analytics ready in Forever Jekyll!!! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi and thank you for this amzng project.
I'm pretty unexperienced user of this tool so if my question is trivial don't waste your time! I was wondering if it's possible to add googl analytics support (as it was done in https://github.com/barryclark/jekyll-now/blob/12cb8a2e97c3b63c4bc92d2a1ab050b35bf946b7/_config.yml#L39). Or if there were some drawbacks in using google analytics instead of the suggested web analytics tool (GoatCounter).
Thank you in advance.
Beta Was this translation helpful? Give feedback.
All reactions