File tree 10 files changed +85
-42
lines changed
10 files changed +85
-42
lines changed Original file line number Diff line number Diff line change @@ -49,11 +49,16 @@ google_site_verification: # fill in to your verification string
49
49
# ↑ --------------------------
50
50
# The end of `jekyll-seo-tag` settings
51
51
52
- google_analytics :
53
- id : # fill in your Google Analytics ID
54
-
55
- goatcounter :
56
- id : # fill in your Goatcounter ID
52
+ # Web Analytics Settings
53
+ analytics :
54
+ google :
55
+ id : # fill in your Google Analytics ID
56
+ goatcounter :
57
+ id : # fill in your GoatCounter ID
58
+
59
+ # Pageviews settings
60
+ pageviews :
61
+ provider : # now only supports 'goatcounter'
57
62
58
63
# Prefer color scheme setting.
59
64
#
Original file line number Diff line number Diff line change
1
+ <!-- GoatCounter -->
2
+ < script
3
+ async
4
+ src ="//gc.zgo.at/count.js "
5
+ data-goatcounter ="https://{{ site.analytics.goatcounter.id }}.goatcounter.com/count "
6
+ > </ script >
Original file line number Diff line number Diff line change
1
+ <!-- Global site tag (gtag.js) - Google Analytics -->
2
+ < script defer src ="https://www.googletagmanager.com/gtag/js?id={{ site.analytics.google.id }} "> </ script >
3
+ < script >
4
+ document . addEventListener ( 'DOMContentLoaded' , function ( event ) {
5
+ window . dataLayer = window . dataLayer || [ ] ;
6
+ function gtag ( ) {
7
+ dataLayer . push ( arguments ) ;
8
+ }
9
+
10
+ gtag ( 'js' , new Date ( ) ) ;
11
+ gtag ( 'config' , '{{ site.analytics.google.id }}' ) ;
12
+ } ) ;
13
+ </ script >
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 72
72
{% endif %}
73
73
74
74
<!-- GA -->
75
- {% if jekyll.environment == 'production' and site.google_analytics. id != empty and site.google_analytics .id %}
75
+ {% if jekyll.environment == 'production' and site.analytics.google. id != empty and site.analytics.google .id %}
76
76
< link rel ="preconnect " href ="https://www.google-analytics.com " crossorigin ="use-credentials ">
77
77
< link rel ="dns-prefetch " href ="https://www.google-analytics.com ">
78
78
Original file line number Diff line number Diff line change 95
95
< script id ="MathJax-script " async src ="{{ site.data.origin[type].mathjax.js | relative_url }} "> </ script >
96
96
{% endif %}
97
97
98
+ <!-- Pageviews -->
99
+ {% if page.layout == 'post' %}
100
+ {% assign provider = site.pageviews.provider %}
101
+
102
+ {% if provider and provider != empty %}
103
+ {% case provider %}
104
+ {% when 'goatcounter' %}
105
+ {% if site.analytics[provider].id != empty and site.analytics[provider].id %}
106
+ {% include pageviews/{{ provider }}.html %}
107
+ {% endif %}
108
+ {% endcase %}
109
+ {% endif %}
110
+ {% endif %}
111
+
98
112
{% if jekyll.environment == 'production' %}
99
113
<!-- PWA -->
100
114
{% if site.pwa.enabled %}
101
115
< script defer src ="{{ 'app.min.js' | prepend: js_dist | relative_url }} "> </ script >
102
116
{% endif %}
103
117
104
- <!-- GA -->
105
- {% if site.google_analytics.id != empty and site.google_analytics.id %}
106
- {% include google-analytics.html %}
107
- {% endif %}
108
-
109
- <!-- GoatCounter -->
110
- {% if site.goatcounter.id != empty and site.goatcounter.id %}
111
- {% include goatcounter.html %}
112
- {% endif %}
118
+ <!-- Web Analytics -->
119
+ {% for analytics in site.analytics %}
120
+ {% capture str %}{{ analytics }}{% endcapture %}
121
+ {% assign type = str | split: '{' | first %}
122
+ {% if site.analytics[type].id and site.analytics[type].id != empty %}
123
+ {% include analytics/{{ type }}.html %}
124
+ {% endif %}
125
+ {% endfor %}
113
126
{% endif %}
Original file line number Diff line number Diff line change
1
+ <!-- Display GoatCounter pageviews -->
2
+ < script >
3
+ let pv = document . getElementById ( 'pageviews' ) ;
4
+
5
+ if ( pv !== null ) {
6
+ const uri = location . pathname . replace ( / \/ $ / , '' ) ;
7
+ const url = `https://{{ site.analytics.goatcounter.id }}.goatcounter.com/counter/${ encodeURIComponent ( uri ) } .json` ;
8
+
9
+ fetch ( url )
10
+ . then ( ( response ) => response . json ( ) )
11
+ . then ( ( data ) => {
12
+ pv . innerText = new Intl . NumberFormat ( ) . format ( data . count ) ;
13
+ } )
14
+ . catch ( ( error ) => {
15
+ pv . innerText = '1' ;
16
+ } ) ;
17
+ }
18
+ </ script >
Original file line number Diff line number Diff line change @@ -74,12 +74,22 @@ <h1 data-toc-skip>{{ page.title }}</h1>
74
74
</ em >
75
75
</ span >
76
76
77
- <!-- read time -->
78
- {% include read-time.html content=content prompt=true lang=lang %}
77
+ < div >
78
+ <!-- pageviews -->
79
+ {% if site.pageviews.provider and site.analytics[site.pageviews.provider].id %}
80
+ < span >
81
+ < em id ="pageviews ">
82
+ < i class ="fas fa-spinner fa-spin small "> </ i >
83
+ </ em >
84
+ {{ site.data.locales[lang].post.pageview_measure }}
85
+ </ span >
86
+ {% endif %}
87
+
88
+ <!-- read time -->
89
+ {% include read-time.html content=content prompt=true lang=lang %}
90
+ </ div >
79
91
</ div >
80
- <!-- .d-flex -->
81
92
</ div >
82
- <!-- .post-meta -->
83
93
</ header >
84
94
85
95
< div class ="content ">
Original file line number Diff line number Diff line change 15
15
}
16
16
17
17
h1 + .post-meta {
18
- > span + span ::before {
18
+ span + span ::before {
19
19
@include dot ;
20
20
}
21
21
You can’t perform that action at this time.
0 commit comments