Skip to content
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

Google Analytics Script Code #85

Closed
muhasturk opened this issue Sep 17, 2014 · 3 comments
Closed

Google Analytics Script Code #85

muhasturk opened this issue Sep 17, 2014 · 3 comments

Comments

@muhasturk
Copy link

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>
@mmistakes
Copy link
Owner

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.

cjmadsen pushed a commit to cjmadsen/cjmadsen.github.io that referenced this issue Dec 7, 2016
Add Gaya theme & Harmony theme updates
cwigington3 pushed a commit to cwigington3/cwigington3.github.io---test that referenced this issue Jan 20, 2017
fix(nav): clicking anywhere when the nav menu is hidden no longer opens it
@ohadschn
Copy link
Contributor

ohadschn commented Sep 16, 2017

@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>

@ohadschn
Copy link
Contributor

For anyone bumping into this as I did:

  1. The so called "Universal Analytics" tracking code requested by @muhasturk is available using google-universal as the analytics provider in _config.yml: https://github.com/mmistakes/minimal-mistakes/blob/master/_includes/analytics-providers/google-universal.html.
  2. It's trivial to just paste whatever analytics code you want (e.g. Google's new "Global Site Tag" I pasted above) in the _includes/analytics-providers/custom.html override and specify custom as the analytics provider ( per the Analytics section in the docs).

theRealSuperMario pushed a commit to theRealSuperMario/therealsupermario.github.io that referenced this issue Jul 18, 2020
nweat pushed a commit to nweat/nweat-old-portfolio that referenced this issue Feb 1, 2023
…/postcss-8.4.16

chore(deps-dev): bump postcss from 8.4.14 to 8.4.16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants