Skip to content

Commit

Permalink
feat(analytics): replace GA with Plausible (#17)
Browse files Browse the repository at this point in the history
Remove Google Analytics tracking and replace it with a self-hosted instance of Plausible. .No more Google spyware.

closes #16
  • Loading branch information
natelandau authored Oct 28, 2022
1 parent bd4f1be commit d507246
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 1,282 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/calibreapp-image-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
- "**.webp"
workflow_dispatch:
jobs:
build:
compress-images:
name: calibreapp/image-actions
runs-on: ubuntu-latest
# Only run on main repo on and PRs that match the main repo.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}

jobs:
build:
deploy-production:
runs-on: ubuntu-latest
steps:
# DEPENDENCIES
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}

jobs:
build:
deploy-staging:
runs-on: ubuntu-latest
steps:
# DEPENDENCIES
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
workflow_dispatch:

jobs:
test_builds:
test-builds:
runs-on: ubuntu-latest
steps:
# DEPENDENCIES
Expand Down
4 changes: 1 addition & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ module.exports = function (grunt) {
jshintrc: true,
reporter: require("jshint-stylish"),
},
beforeconcat: ["site/_js/{,*/}*.js", "!site/_js/autotrack.js", "!site/_js/jquery.min.js"],
beforeconcat: ["site/_js/{,*/}*.js", "!site/_js/jquery.min.js"],
},

uglify: {
Expand All @@ -138,7 +138,6 @@ module.exports = function (grunt) {
files: {
"site/assets/customScripts.js": [
"site/_js/jquery.min.js",
"site/_js/autotrack.js",
"site/_js/custom.js",
"site/_js/jquery.fitvids.js",
"site/_js/webfont.js",
Expand All @@ -153,7 +152,6 @@ module.exports = function (grunt) {
files: {
"site/assets/customScripts.js": [
"site/_js/jquery.min.js",
"site/_js/autotrack.js",
"site/_js/custom.js",
"site/_js/jquery.fitvids.js",
"site/_js/webfont.js",
Expand Down
3 changes: 1 addition & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
# Environment Specific
environment: dev
url: "http://localhost:8000"
analyticsID: UA-80560-6
destination: ./_site
include-js: true
giscus_data_category_id: DIC_kwDOIM6z9s4CSAJf
giscus_data_category: staging-comments
plausible_domain: "staging.natelandau.com"

# Shared options
# ------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions _config_production.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
environment: production
url: "https://natelandau.com"
analyticsID: UA-80560-5
destination: ./_siteProd
include-js: true
giscus_data_category_id: DIC_kwDOIM6z9s4CSACn
giscus_data_category: Comments
plausible_domain: "natelandau.com"
3 changes: 1 addition & 2 deletions _config_staging.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
environment: staging
url: "https://staging.natelandau.com"
analyticsID: UA-80560-6
disqusShortName: natelandaudev
destination: ./_siteStage
include-js: true
giscus_data_category_id: DIC_kwDOIM6z9s4CSAJf
giscus_data_category: staging-comments
plausible_domain: "staging.natelandau.com"
7 changes: 5 additions & 2 deletions site/_includes/global.footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
<a href="https://feeds.natelandau.com/rss"><i class="fa fa-rss"></i>&nbsp;&nbsp;RSS Feed</a><br />
<a href="{{ site.url }}/feed.json"><i class="fa fa-link"></i>&nbsp;&nbsp;JSON Feed</a>
<br /><br />
This site does NOT use Google Analytics.
<br /><br />
<span class="normal">&copy; Copyright {{ site.time | date: '%Y' }}. All Rights Reserved.</span>
<br /><br />
</div><!-- /lower-item -->

<div class="lower-item">
Expand Down Expand Up @@ -52,7 +55,7 @@
The following code defers loading of Javascript until after the page is fully loaded
As taken from: https://varvy.com/pagespeed/defer-loading-javascript.html
{% endcomment %}
{% if site.include-js != false -%}

<script type="text/javascript">
function downloadJSAtOnload() {
var element = document.createElement("script");
Expand All @@ -65,7 +68,7 @@
window.attachEvent("onload", downloadJSAtOnload);
else window.onload = downloadJSAtOnload;
</script>
{% endif -%}


{% if post.youtubeEmbed == "true" -%}
<script type="text/javascript">
Expand Down
2 changes: 1 addition & 1 deletion site/_includes/global.header.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{% include header.twittercard.html %}
{% include header.favicons.html %}
{% include header.css.html %}
{% if site.include-js != false %}{% include header.analytics.html %}{% endif %}
{% include header.analytics.html %}
</head>
<body id="{{ page.layout }}">
<div class="page-top"></div>
Expand Down
24 changes: 1 addition & 23 deletions site/_includes/header.analytics.html
Original file line number Diff line number Diff line change
@@ -1,23 +1 @@
<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.analyticsID }}', 'auto');

// autotrack.js plugins
ga('require', 'eventTracker');
ga('require', 'outboundLinkTracker');
ga('require', 'pageVisibilityTracker');
ga('require', 'socialWidgetTracker');

{% if page.title == "404: Page not found | Nathaniel Landau" -%}
ga('send', 'pageview', {
'page': '{{ page.url }}',
'title': '404: Page not found'
});
{% else -%}
ga('require', 'linkid');
ga('send', 'pageview');
{% endif -%}
</script>
<script defer data-domain="{{ site.plausible_domain }}" src="https://stats.natenate.org/js/script.outbound-links.js"></script>
Loading

0 comments on commit d507246

Please sign in to comment.