My google analytics says you should use the following code to analysis site.
<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', 'UA-XXXXXXXX-X', 'auto');
ga('send', 'pageview');
</script>
so why we do use this script in _includes/_scripts.html? Are they the same code?
<script>
var _gaq = _gaq || [];
var pluginUrl =
'//www.google-analytics.com/plugins/ga/inpage_linkid.js';
_gaq.push(['_require', 'inpage_linkid', pluginUrl]);
_gaq.push(['_setAccount', '{{ site.owner.google.analytics }}']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
The theme is using the Classic Google Analytics script. What you included above is the new Universal one that everyone should eventually move to.
I didn't update it to avoid breaking things for those who haven't turned it on yet in GA.
Just update your copy of _scripts.html to match the new Universal script and you should be fine.
@mmistakes any news here? Looks like the old code is still there... BTW The latest recommendation looks like this (note that the tracking code appears twice, in the script query string and in the gtag call):
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-12345678-9"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag('js', new Date());
gtag('config', 'UA-12345678-9');
</script>
For anyone bumping into this as I did:
google-universal as the analytics provider in _config.yml: https://github.com/mmistakes/minimal-mistakes/blob/master/_includes/analytics-providers/google-universal.html._includes/analytics-providers/custom.html override and specify custom as the analytics provider ( per the Analytics section in the docs).
Most helpful comment
For anyone bumping into this as I did:
google-universalas the analytics provider in_config.yml: https://github.com/mmistakes/minimal-mistakes/blob/master/_includes/analytics-providers/google-universal.html._includes/analytics-providers/custom.htmloverride and specifycustomas the analytics provider ( per the Analytics section in the docs).