Skip to content

Commit 990c3f3

Browse files
add ga4 gtag (#352)
* add ga4 gtag * fix env var handling and loading in workflow
1 parent dd41de0 commit 990c3f3

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

.github/workflows/deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
5757
ALGOLIA_SEARCH_KEY: ${{ secrets.ALGOLIA_SEARCH_KEY }}
5858
ALGOLIA_INDEX_NAME: ${{ secrets.ALGOLIA_INDEX_NAME }}
59+
GA4_TRACKING_ID: ${{ secrets.GA4_TRACKING_ID }}
5960
run: |
6061
echo "Building Docusaurus site..."
6162
echo "Using DOCUSAURUS_ROUTE_BASE_PATH: $DOCUSAURUS_ROUTE_BASE_PATH"

docusaurus.config.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,19 @@ const config: Config = {
243243
},
244244
},
245245
],
246+
247+
// GA4
248+
...(process.env.GA4_TRACKING_ID
249+
? [
250+
[
251+
'@docusaurus/plugin-google-gtag',
252+
{
253+
trackingID: process.env.GA4_TRACKING_ID || '',
254+
anonymizeIP: true,
255+
},
256+
],
257+
]
258+
: []),
246259
],
247260

248261
themes: [

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"dependencies": {
2424
"@docusaurus/core": "3.9.1",
2525
"@docusaurus/plugin-client-redirects": "3.9.1",
26+
"@docusaurus/plugin-google-gtag": "^3.9.1",
2627
"@docusaurus/preset-classic": "3.9.1",
2728
"@docusaurus/remark-plugin-npm2yarn": "3.9.1",
2829
"@docusaurus/theme-mermaid": "3.9.1",

0 commit comments

Comments
 (0)