forked from cotes2020/jekyll-theme-chirpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(analytics)!: add post pageviews for GoatCounter (cotes2020#1543)
--------- Co-authored-by: Cotes Chung <[email protected]>
- Loading branch information
Showing
10 changed files
with
85 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!-- GoatCounter --> | ||
<script | ||
async | ||
src="//gc.zgo.at/count.js" | ||
data-goatcounter="https://{{ site.analytics.goatcounter.id }}.goatcounter.com/count" | ||
></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Global site tag (gtag.js) - Google Analytics --> | ||
<script defer src="https://www.googletagmanager.com/gtag/js?id={{ site.analytics.google.id }}"></script> | ||
<script> | ||
document.addEventListener('DOMContentLoaded', function (event) { | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag() { | ||
dataLayer.push(arguments); | ||
} | ||
|
||
gtag('js', new Date()); | ||
gtag('config', '{{ site.analytics.google.id }}'); | ||
}); | ||
</script> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!-- Display GoatCounter pageviews --> | ||
<script> | ||
let pv = document.getElementById('pageviews'); | ||
|
||
if (pv !== null) { | ||
const uri = location.pathname.replace(/\/$/, ''); | ||
const url = `https://{{ site.analytics.goatcounter.id }}.goatcounter.com/counter/${encodeURIComponent(uri)}.json`; | ||
|
||
fetch(url) | ||
.then((response) => response.json()) | ||
.then((data) => { | ||
pv.innerText = new Intl.NumberFormat().format(data.count); | ||
}) | ||
.catch((error) => { | ||
pv.innerText = '1'; | ||
}); | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
} | ||
|
||
h1 + .post-meta { | ||
> span + span::before { | ||
span + span::before { | ||
@include dot; | ||
} | ||
|
||
|