-
Notifications
You must be signed in to change notification settings - Fork 78
Description
In the past I set up Google Analytics on my blog (the source is here) and it worked nicely. Recently, I got an update from Google that there are some updates rolling out and I should update the way Google Analytics is integrated into my pages.
In particular, I understand that the new fashion of integration is:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXX-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXX-1');
</script>
and it says:
This is the Global Site Tag (gtag.js) tracking code for this property. Copy and paste this code as the first item into the of every webpage you want to track. If you already have a Global Site Tag on your page, simply add the config line from the snippet below to your existing Global Site Tag.
Currently (ref), in my blog, I have the following (coming from this Alchemy repo):
{% if 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);
a.async = 1;
a.src = g;
m = s.getElementsByTagName(o)[0];
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', '{{ GOOGLE_ANALYTICS }}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}
If I understand correctly, this is what has to be updated. Am I right? Am I missing something? Thanks in advance for your support!