Skip to content

Commit 671f92b

Browse files
committed
feat: ✨ integrate google analytics
1 parent f6a6ff1 commit 671f92b

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ launch:
55
# Local build the website
66
build:
77
jekyll build
8+
# Test Google Analytics
9+
build-prod:
10+
JEKYLL_ENV=production jekyll build
811
# Generate pdf files
912
pdf:
1013
bash ${PWD}/bin/pdf-product2.sh

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Made a Github Page repo in order to use one single data.yaml file to generate a
1616
- `echo 'export PATH="/usr/local/lib/ruby/gems/3.1.0/bin:$PATH"' >> ~/.zshrc`
1717
- Ruby 3.0.0+: `bundle add webrick` + `bundle clean --force`
1818
- Set up Prince from [here](https://idratherbewriting.com/documentation-theme-jekyll/mydoc_generating_pdfs.html#1-set-up-prince)
19+
- Set up Google Analytics [here](https://desiredpersona.com/google-analytics-jekyll/)
1920
- Follow the project root directory `Makefile`
2021

2122

_config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ location: Houston, TX
3030
linkedin: https://www.linkedin.com/in/drewyang/
3131
github: https://github.com/yambottle
3232
website: https://yambottle.github.io/me/more.html
33+
google_analytics: G-G8FDXGZ48K
3334

3435
# Build settings
3536
encoding: "utf-8"

_includes/analytics.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
2+
<script>
3+
window.dataLayer = window.dataLayer || [];
4+
function gtag(){dataLayer.push(arguments);}
5+
gtag('js', new Date());
6+
7+
gtag('config', '{{ site.google_analytics }}');
8+
</script>

_includes/head.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,8 @@
2929
<!-- Custom CSS -->
3030
<link rel="stylesheet" href="{{ site.baseurl }}/assets/css/styles.css">
3131

32+
{% if site.google_analytics and jekyll.environment == 'production' %}
33+
{% include analytics.html %}
34+
{% endif %}
35+
3236
</head>

0 commit comments

Comments
 (0)