Skip to content

Commit 0a1f179

Browse files
authored
Add google analytics integration (#18)
* Install vue-gtag plugin * Register gtag * Add gtag measurmentId to global config * Add measurementid to docs site
1 parent b6945f1 commit 0a1f179

File tree

5 files changed

+54
-2
lines changed

5 files changed

+54
-2
lines changed

app.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ interface ExactproDocsOptions {
6262
content: string
6363
}[]
6464
}
65+
gtag?: {
66+
measurementId?: string
67+
}
6568
social?: {
6669
githhub?: SocialLinkConfigOptions
6770
facebook?: SocialLinkConfigOptions

docs/app.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ export default defineAppConfig({
3939
content: 'PYzR06VK4UIZvGdBkMh_TkqOu83QxapFJknyAR58yJA'
4040
}
4141
]
42+
},
43+
gtag: {
44+
measurementId: 'G-BD6STVYLJK'
4245
}
4346
}
4447
})

package-lock.json

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@types/mermaid": "^9.2.0",
6060
"nuxt": "^3.3.1",
6161
"nuxt-icon": "^0.3.3",
62-
"rehype-external-links": "^2.1.0"
62+
"rehype-external-links": "^2.1.0",
63+
"vue-gtag-next": "^1.14.0"
6364
}
6465
}

plugins/gtag.client.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2023 Exactpro (Exactpro Systems Limited)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import VueGtag from 'vue-gtag-next'
18+
19+
export default defineNuxtPlugin((nuxtApp) => {
20+
const config = useAppConfig()
21+
const measurementId = config.exactproDocs.gtag?.measurementId
22+
if (!measurementId) {
23+
return
24+
}
25+
nuxtApp.vueApp.use(VueGtag, {
26+
property: {
27+
id: measurementId
28+
}
29+
})
30+
})

0 commit comments

Comments
 (0)