academicpages / academicpages.github.io

Github Pages template for academic personal websites, forked from mmistakes/minimal-mistakes
https://academicpages.github.io
MIT License
12.3k stars 43.58k forks source link

Struggling to get google analytics to work #265

Open Erica-Ryan opened 5 years ago

Erica-Ryan commented 5 years ago

I added my tracking ID to the config, in double quotes. However, google analytics is not logging any hits even though I'm testing it.

I've looked at other documentation and I know the code google analytics is providing me is different from the google_universal.html file. But I'm not sure if that means it has actually changed or if they do the same thing and I just don't understand them. I also saw on other guides that my Jekyll environment should be production? I'm not sure sure what that means for this repo.

MatisPatel commented 4 years ago

I am having the same issue. Copied my tracking ID into the _config.yml but no tracking seems to occur.

Linear95 commented 4 years ago

Hi, I came up with the same issue, but solved it by first change provider of analytics to "custom" in _config.yml, then directly copy your google analytics tracking code to _includes/analytics-providers/custom.html. Hope this can help :)

JulianKlug commented 4 years ago

Worked for me! Maybe this should be added in the comment in the _config.yml?

pantonik commented 3 years ago

Worked for me as well! Looks like Google changed the tracking script, so the one included in academicpages no longer works...

rogerioagjr commented 3 years ago

This really works, thanks!

saideepesh commented 2 years ago

Has Google Analytics stopped working for anyone else? It worked just fine with the 'custom' solution mentioned above, however, it stopped working since a month now.

ozlemtuncel commented 1 year ago

I have the same issue and custom solution does not work. As of January 2023, universal analytics tracking code will not work and switching to google analytics 4 is necessary. I have tried different things (like this stackoverflow answers) but could not figure it out!

tnybny commented 1 year ago

You just have to go a little further and it works fine. The following steps are needed:

  1. Set provider: "custom" in the _config.yml file.
  2. add your website's google tag script that you're given when you sign up for analytics 4 to _includes/analytics-providers/custom.html. It looks something like
    
    <script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_TAG"></script>
    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
gtag('config', YOUR_TAG'); ``` 3. From `_includes/scripts.html`, remove the line `{% include analytics.html %}`. 4. In `_layouts/default.html`, add `{% include analytics.html %}` right after the `` line.
ozlemtuncel commented 1 year ago

You just have to go a little further and it works fine. The following steps are needed:

  1. Set provider: "custom" in the _config.yml file.
  2. add your website's google tag script that you're given when you sign up for analytics 4 to _includes/analytics-providers/custom.html. It looks something like
<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_TAG"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

<!-- end custom analytics snippet -->   gtag('config', YOUR_TAG');
</script>
  1. From _includes/scripts.html, remove the line {% include analytics.html %}.
  2. In _layouts/default.html, add {% include analytics.html %} right after the <head> line.

Works perfect! Thank you so much!

viniciuspr88 commented 1 year ago

You just have to go a little further and it works fine. The following steps are needed:

  1. Set provider: "custom" in the _config.yml file.
  2. add your website's google tag script that you're given when you sign up for analytics 4 to _includes/analytics-providers/custom.html. It looks something like
<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_TAG"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

<!-- end custom analytics snippet -->   gtag('config', YOUR_TAG');
</script>
  1. From _includes/scripts.html, remove the line {% include analytics.html %}.
  2. In _layouts/default.html, add {% include analytics.html %} right after the <head> line.

This is super helpful. Many thanks!

jaywt commented 1 year ago

You just have to go a little further and it works fine. The following steps are needed:

  1. Set provider: "custom" in the _config.yml file.
  2. add your website's google tag script that you're given when you sign up for analytics 4 to _includes/analytics-providers/custom.html. It looks something like
<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_TAG"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

<!-- end custom analytics snippet -->   gtag('config', YOUR_TAG');
</script>
  1. From _includes/scripts.html, remove the line {% include analytics.html %}.
    1. In _layouts/default.html, add {% include analytics.html %} right after the <head> line.

Fantastic! Thanks!

ZijingWu381 commented 1 year ago

You just have to go a little further and it works fine. The following steps are needed:

  1. Set provider: "custom" in the _config.yml file.
  2. add your website's google tag script that you're given when you sign up for analytics 4 to _includes/analytics-providers/custom.html. It looks something like
<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_TAG"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

<!-- end custom analytics snippet -->   gtag('config', YOUR_TAG');
</script>
  1. From _includes/scripts.html, remove the line {% include analytics.html %}.
  2. In _layouts/default.html, add {% include analytics.html %} right after the <head> line.

Awesome. Thank you!

yxwu1999 commented 1 year ago

You just have to go a little further and it works fine. The following steps are needed:

  1. Set provider: "custom" in the _config.yml file.
  2. add your website's google tag script that you're given when you sign up for analytics 4 to _includes/analytics-providers/custom.html. It looks something like
<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_TAG"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

<!-- end custom analytics snippet -->   gtag('config', YOUR_TAG');
</script>
  1. From _includes/scripts.html, remove the line {% include analytics.html %}.
  2. In _layouts/default.html, add {% include analytics.html %} right after the <head> line.

Fantastic! Very simple and clear

viniciuspr88 commented 1 year ago

You just have to go a little further and it works fine. The following steps are needed:

  1. Set provider: "custom" in the _config.yml file.
  2. add your website's google tag script that you're given when you sign up for analytics 4 to _includes/analytics-providers/custom.html. It looks something like
<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_TAG"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

<!-- end custom analytics snippet -->   gtag('config', YOUR_TAG');
</script>
  1. From _includes/scripts.html, remove the line {% include analytics.html %}.
  2. In _layouts/default.html, add {% include analytics.html %} right after the <head> line.

Hi everyone, I followed the steps outlined by @tnybny a couple of months ago and it worked beautifully. But my Google Analytics dashboard now says it stopped collecting data and I cannot seem to find a way to fix it. Anyone had the same issue and could advise? Many thanks!

rjzupkoii commented 1 month ago

It looks like Google has updated analytics again so this might be more than just a documentation task. Since I don't use analytics on my own site, this might also be a good item for others to help out with.