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

Changes to google analytics #90

Open
drorata opened this issue Aug 24, 2022 · 1 comment
Open

Changes to google analytics #90

drorata opened this issue Aug 24, 2022 · 1 comment

Comments

@drorata
Copy link

drorata commented Aug 24, 2022

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!

@martbhell
Copy link

Ah. Looks like I'm on the right track in #91

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants