Skip to content

Commit

Permalink
fix(ga4): using tag instead of google analytics id (#376)
Browse files Browse the repository at this point in the history
Co-authored-by: Cameron Motevasselani <[email protected]>
  • Loading branch information
link108 and Cameron Motevasselani authored Sep 12, 2023
1 parent f92f49f commit 7713e9f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ anchor = "smart"

[services]
[services.googleAnalytics]
# Comment out the next line to disable GA tracking. Also disables the feature described in [params.ui.feedback].
# Comment out the id to disable the feature described in [params.ui.feedback].
# This ID can be found in Google Analytics -> Admin Panel -> Data Streams -> Spinnaker Website - GA4 -> Measurement ID
id = "G-H0XE7ESBFR"

Expand Down Expand Up @@ -96,6 +96,10 @@ copyright = 'Copyright © 2020 The Linux Foundation®. All rights reserved. The
privacy_policy = "http://www.linuxfoundation.org/privacy"
terms_of_use = "http://www.linuxfoundation.org/terms"

# Comment out the next line to disable GA tracking.
# This Tag ID can be found in Google Analytics -> Admin Panel -> Data Streams -> Spinnaker Website - GA4 -> Configure Tag Settings
google_tag_id="GT-W6BN9SN"

# First one is picked as the Twitter card image if not set on page.
# images = ["images/project-illustration.png"]

Expand Down
8 changes: 8 additions & 0 deletions layouts/partials/google-analytics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!--This function is from tagmanager.google.com's installation instructions -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ .Site.Params.google_tag_id }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', "{{ .Site.Params.google_tag_id }}");
</script>
3 changes: 0 additions & 3 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
{{- template "_internal/google_news.html" . -}}
{{- template "_internal/schema.html" . -}}
{{- template "_internal/twitter_cards.html" . -}}
{{ if eq (getenv "HUGO_ENV") "production" }}
{{ template "_internal/google_analytics.html" . }}
{{ end }}
{{ partialCached "head-css.html" . "asdf" }}
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
Expand Down
3 changes: 3 additions & 0 deletions layouts/partials/hooks/head-end.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
{{ $desc := (.Page.Content | safeHTML | truncate 150) }}
<meta name="description" content="{{ $desc }}">
{{ end }}
{{ if eq (getenv "HUGO_ENV") "production" }}
{{ partial "google-analytics.html" . }}
{{end}}

0 comments on commit 7713e9f

Please sign in to comment.