Skip to content

Commit 6e725fd

Browse files
taqrotakuro saito
and
takuro saito
authored
Set Google Analytics (GA4) tracking code in Jupyter book (#41)
Co-authored-by: takuro saito <t.saito@j-ij.com>
1 parent c2617e0 commit 6e725fd

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

.github/workflows/docs.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ jobs:
3030
uv sync --all-extras --dev
3131
3232
- name: Build the book
33+
env:
34+
GA4_TRACKING_ID: ${{ secrets.GA4_TRACKING_ID }}
3335
run: |
36+
# Replace GA4_TRACKING_ID placeholder with actual value from secrets
37+
# Using | as delimiter to avoid issues with / in the GA4 ID
38+
sed -i "s|GA4_TRACKING_ID|${GA4_TRACKING_ID}|g" docs/${{ matrix.lang }}/_config.yml
39+
40+
# Build the book
3441
uv run jupyter-book build docs/${{ matrix.lang }}
3542
ERROR_LOGS=$(find docs/${{ matrix.lang }}/_build -type f -name "*.err.log")
3643
if [ -n "$ERROR_LOGS" ]; then while IFS= read -r log; do echo "[ERROR LOG] $log" && cat "$log"; done <<< "$ERROR_LOGS" && exit 1; fi

docs/en/_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ html:
3232
favicon: "./logo.png"
3333
use_issues_button: true
3434
use_repository_button: true
35+
analytics:
36+
google_analytics_id: GA4_TRACKING_ID
3537

3638
launch_buttons:
3739
notebook_interface: "classic"

docs/ja/_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ html:
3232
favicon: "./logo.png"
3333
use_issues_button: true
3434
use_repository_button: true
35+
analytics:
36+
google_analytics_id: GA4_TRACKING_ID
3537

3638
launch_buttons:
3739
notebook_interface: "classic"

0 commit comments

Comments
 (0)