Skip to content

Commit 6f7c788

Browse files
fix(ga): add google analytics
add the ga measurement id
1 parent bcdfb59 commit 6f7c788

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

frontend/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33

44
<head>
55
<meta charset="utf-8" />
6+
{{$ga := env "GA_MEASUREMENT_ID"}}{{if $ga}}
7+
<script async src="https://www.googletagmanager.com/gtag/js?id={{$ga}}"></script>
8+
<script>
9+
window.dataLayer = window.dataLayer || [];
10+
function gtag() { dataLayer.push(arguments); }
11+
gtag('js', new Date());
12+
gtag('config', '{{$ga}}');
13+
</script>
14+
{{end}}
615
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
716
<meta name="theme-color" content="#2D5F3F" />
817
<script>

infra/.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ OSMSG_FRONTEND_DOMAIN=osmsg.osgeonepal.org
33
OSMSG_API_DOMAIN=api.osmsg.osgeonepal.org
44
OSMSG_ACME_EMAIL=admin@osgeonepal.org
55

6+
# Google Analytics measurement id. Set it to enable gtag.js on the frontend (Caddy injects the snippet
7+
# into index.html only when this is non-empty); leave empty to serve the site with no analytics.
8+
GA_MEASUREMENT_ID=
9+
610
# Worker cold start (no resume state): begins at day granularity and --update auto-refines to hour then
711
# minute as the backlog shrinks. OSMSG_BOOTSTRAP_DAYS sets the cold-start window (default 1 day).
812
# OSMSG_SCHEDULE=*/2 * * * *

infra/Caddyfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
handle {
1414
root * /srv/leaderboard
15+
templates
1516
try_files {path} {path}/ /index.html
1617
file_server
1718
}

0 commit comments

Comments
 (0)