yaoyao-liu / minimal-light

A simple and elegant Jekyll theme for an academic personal homepage
https://minimal-light-theme.yliu.me
Creative Commons Zero v1.0 Universal
605 stars 498 forks source link

how to set google analytics? #3

Open Oran-Ac opened 2 years ago

Oran-Ac commented 2 years ago

Hi, I would like to ask if the google analytics can be used by just changing the settings in _config.yml google_analytics: UA-111540567-4 I tried but I couldn't get any data in google analytics

yaoyao-liu commented 2 years ago

If changing the setting in _config.yml doesn't work, you may replace the following lines in /_layouts/homepage.html with the code provided by Google Analytics: https://github.com/yaoyao-liu/minimal-light/blob/599feb2dfe99d28a836efb0bd3aaa45743c2c23a/_layouts/homepage.html#L84-L91

shuhanmirza commented 11 months ago

@yaoyao-liu please replace the code for g-analytics with below code. I intended to open a PR for this. However, the repo does not provide permission to create a new branch.

    {% if site.google_analytics %}
    <!-- Google tag (gtag.js) -->
    <script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', '{{ site.google_analytics }}');
    </script>
    {% endif %}
MING-ZCH commented 1 month ago

@yaoyao-liu please replace the code for g-analytics with below code. I intended to open a PR for this. However, the repo does not provide permission to create a new branch.

    {% if site.google_analytics %}
    <!-- Google tag (gtag.js) -->
    <script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', '{{ site.google_analytics }}');
    </script>
    {% endif %}

hi, I tried your code but failed, too. Is this the completed code?