Skip to content

Set Google Analytics (GA4) tracking code in Jupyter book #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ jobs:
uv sync --all-extras --dev

- name: Build the book
env:
GA4_TRACKING_ID: ${{ secrets.GA4_TRACKING_ID }}
run: |
# Replace GA4_TRACKING_ID placeholder with actual value from secrets
# Using | as delimiter to avoid issues with / in the GA4 ID
sed -i "s|GA4_TRACKING_ID|${GA4_TRACKING_ID}|g" docs/${{ matrix.lang }}/_config.yml

# Build the book
uv run jupyter-book build docs/${{ matrix.lang }}
ERROR_LOGS=$(find docs/${{ matrix.lang }}/_build -type f -name "*.err.log")
if [ -n "$ERROR_LOGS" ]; then while IFS= read -r log; do echo "[ERROR LOG] $log" && cat "$log"; done <<< "$ERROR_LOGS" && exit 1; fi
Expand Down
2 changes: 2 additions & 0 deletions docs/en/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ html:
favicon: "./logo.png"
use_issues_button: true
use_repository_button: true
analytics:
google_analytics_id: GA4_TRACKING_ID

launch_buttons:
notebook_interface: "classic"
Expand Down
2 changes: 2 additions & 0 deletions docs/ja/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ html:
favicon: "./logo.png"
use_issues_button: true
use_repository_button: true
analytics:
google_analytics_id: GA4_TRACKING_ID

launch_buttons:
notebook_interface: "classic"
Expand Down