Skip to content

Commit

Permalink
try google tag id
Browse files Browse the repository at this point in the history
  • Loading branch information
melhuang committed Feb 6, 2024
1 parent 52e536e commit 81e63b2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: github pages
on:
push:
branches:
- master # Set a branch that will trigger a deployment
- master # Set a branch that will trigger a deployment
pull_request:

jobs:
Expand All @@ -12,13 +12,13 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
submodules: true # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
submodules: true # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod

- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: 'latest'
hugo-version: "latest"
# extended: true

- name: Build
Expand All @@ -30,3 +30,5 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
env:
GOOGLE_ANALYTICS_ID: ${{ secrets.GOOGLE_ANALYTICS_ID }}
5 changes: 1 addition & 4 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,4 @@ weight = 1
[[menu.main]]
name = "About"
url = "/pages/about"
weight = 2

[[Analytics]]
googleAnalyticsID = "G-3YJ9SZ6HYY"
weight = 2
6 changes: 3 additions & 3 deletions themes/ghostwriter/layouts/partials/analytics-gtag.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ .Site.Params.googleAnalyticsID }}"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id={{process.env.GOOGLE_ANALYTICS_ID}}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ .Site.Params.googleAnalyticsID }}');
gtag('config', '{{ process.env.GOOGLE_ANALYTICS_ID }}');
</script>
4 changes: 1 addition & 3 deletions themes/ghostwriter/layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
{{ partial "exponea.html" . }}
{{ partial "fathom.html" . }}
{{ partial "plausible.html" . }}
{{ if .Site.Params.googleAnalyticsID }}
{{ partial "analytics-gtag.html" . }}
{{ end }}
{{ partial "analytics-gtag.html" . }}
</head>
<body>
{{ template "_internal/google_analytics.html" . }}
Expand Down

0 comments on commit 81e63b2

Please sign in to comment.