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 #105

Open
herediiaa opened this issue Dec 29, 2022 · 2 comments
Open

google analytics #105

herediiaa opened this issue Dec 29, 2022 · 2 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@herediiaa
Copy link

hi, i am having a problem form google analytics, i can not set up it.
i have changed the code from includes/extensions/google-analytics.html
and now is like this:

<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
<script>
  function initGoogleAnalytics() {
    var doNotTrack = (window.doNotTrack === "1" || navigator.doNotTrack === "1" ||
      navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1");
    var enableDNT = "{{ site.enableDNT | default: true }}" == "true";

    if (!enableDNT || !doNotTrack) {
      window.dataLayer = window.dataLayer || [];
      function gtag(){window.dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', '{{ site.google_analytics }}');
        }
  }
  window.addEventListener("load", initGoogleAnalytics);
</script>
```

and my  `_config.yml`  

```
# Google analytics
google_analytics: [G-9DDM93FC22]
```

what is my error?

@leabs
Copy link

leabs commented Feb 1, 2023

The conditions for the _includes/extensions/google-analytics.html to populate in the _includes/head.html are if the google_analytics property is set in the _config.yml (yours is) AND the jekyll environment is set to production.

This can be done by running JEKYLL_ENV=production jekyll build.

@jeffreytse jeffreytse self-assigned this Feb 1, 2023
@jeffreytse jeffreytse added the good first issue Good for newcomers label Feb 1, 2023
@jeffreytse
Copy link
Owner

jeffreytse commented Jun 24, 2023

Hi @herediiaa @leabs ,

I just updated to support GA4, please see #112. Thanks for supporting YAT theme.

Thanks & Regards

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

No branches or pull requests

3 participants