feat: add google analytics
This commit is contained in:
@@ -91,6 +91,7 @@ import {
|
||||
NOT_COMPATIBLE_AGENTS,
|
||||
TRIGGER_PROBABILITY,
|
||||
} from '@/utils/constant'
|
||||
import { recordClick } from '@/utils/ga'
|
||||
|
||||
import Confetti from './components/Confetti.vue'
|
||||
|
||||
@@ -175,6 +176,10 @@ function handleAction(actionType: ActionType) {
|
||||
|
||||
case ActionType.Code:
|
||||
codeVisible.value = !codeVisible.value
|
||||
recordClick({
|
||||
event_category: 'code',
|
||||
event_label: 'view code',
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
5
src/env.d.ts
vendored
5
src/env.d.ts
vendored
@@ -6,3 +6,8 @@ declare module '*.vue' {
|
||||
const component: DefineComponent<{}, {}, any>
|
||||
export default component
|
||||
}
|
||||
|
||||
interface Window {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
gtag: any
|
||||
}
|
||||
|
||||
7
src/utils/ga.ts
Normal file
7
src/utils/ga.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export function recordClick(params: {
|
||||
event_category: string
|
||||
event_label?: string
|
||||
value?: number
|
||||
}) {
|
||||
window?.gtag('event', 'Click', params)
|
||||
}
|
||||
Reference in New Issue
Block a user