-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Google Analytics #100
Conversation
Closes #88
Welcome! Congrats on your first pull request to the Minimal theme. If you haven't already, please be sure to check out the contributing guidelines. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the documentation, it's recommended to put the gtag.js into the <head>
.
From the setup procedures:
Copy the global site tag into the section of your HTML.
Hi! You can now customize the Google Analytics code by using an include in your site: https://github.com/pages-themes/minimal#customizing-google-analytics-code |
@parkr Why is this closed? I just wasted around 20-30 minutes with this not being merged. The PR looks fine. Can we replace {% if site.google_analytics %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');
</script>
{% endif %} with <!-- 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());
gtag('config', '{{ site.google_analytics }}');
</script> As per Google's official recommendation? This removes the need for users to manually create the file themselves and being a bit lost as to why GA isn't working. |
This is cool but having the default be compatible with Google V4 would make more sense IMHO. |
can we re-open this? |
* add google analytics * fix google analytics - pages-themes/minimal#245 * fix google analytics (pt 3) - pages-themes/minimal#100
Closes #88