Skip to content
This repository was archived by the owner on Jul 26, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,12 @@ Add your username on selected websites in the icon section of the `_config.yml`
Change these variables in `_config.yml`:


| Variable | Example | Description | Optional |
| ---------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------- | -------- |
| google_analytics | UA-123456-01 | Google Analytics [tracking ID](https://support.google.com/analytics/answer/1032385?hl=en) | Yes |
| disqus_shortname | shortname | Disqus [shortname](https://help.disqus.com/customer/portal/articles/466208-what-s-a-shortname-) | Yes |
| katex | true | Takes boolean value (true/false) to conditionally load [KaTeX](https://khan.github.io/KaTeX/) scripts required for math typesetting | Yes |
| Variable | Example | Description | Optional |
| ------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------- | -------- |
| google_analytics | UA-123456-01 | Google Analytics [tracking ID](https://support.google.com/analytics/answer/1032385?hl=en) | Yes |
| google_analytics_v4 | G-ABCD123456 | Google Analytics [tracking ID](https://support.google.com/analytics/answer/10759417) | Yes |
| disqus_shortname | shortname | Disqus [shortname](https://help.disqus.com/customer/portal/articles/466208-what-s-a-shortname-) | Yes |
| katex | true | Takes boolean value (true/false) to conditionally load [KaTeX](https://khan.github.io/KaTeX/) scripts required for math typesetting | Yes |

Scripts listed here are only loaded if you provide a value in the `_config.yml` file.

Expand Down
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ theme_settings:
youtube:

# Scripts
google_analytics: # Tracking ID, e.g. "UA-000000-01"
google_analytics_v4: # Tracking ID, e.g. "G-000000001"
disqus_shortname:
katex: true # Enable if using math markup
search: false # Enable the search feature
Expand Down
23 changes: 10 additions & 13 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,15 @@
crossorigin="anonymous"></script>
{% endif %}

<!-- Google Analytics -->
{% if site.theme_settings.google_analytics %}
<!-- Google Analytics v4 -->
{% if site.theme_settings.google_analytics_v4 %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.theme_settings.google_analytics_v4 }}"></script>
<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', '{{ site.theme_settings.google_analytics }}', 'auto');
ga('send', 'pageview');
</script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

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