Skip to content

Commit

Permalink
fdg
Browse files Browse the repository at this point in the history
  • Loading branch information
neerajrekwar committed Aug 7, 2024
1 parent 3cc730f commit 4ec9d58
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/gtag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,25 @@ export type Event = (ClickEvent) & {
value?: string
}

declare global {
interface Window {
gtag: (...args: any[]) => void; // Add this line
}
}
export const pageview = (path: string) => {
if (!existsGaId) {
return
}

window.gtag('config', GA_ID, {
page_path: path,
})
(window as any).gtag('config', GA_ID, { page_path: path });
}

export const event = ({ action, category, label, value = '' }: Event) => {
if (!existsGaId) {
return
}

window.gtag('event', action, {
(window as any).gtag('event', action, {
event_category: category,
event_label: label ? JSON.stringify(label) : '',
value,
Expand Down

0 comments on commit 4ec9d58

Please sign in to comment.