Skip to content

Commit

Permalink
Update ga4.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Dec 28, 2024
1 parent 4815708 commit 0108016
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions frontend/src/common/ga4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import env from '@/config/env.config'
const TRACKING_ID = env.GOOGLE_ANALYTICS_ID
const { isProduction } = env

// export const init = () => ga4.initialize(TRACKING_ID, {
// testMode: !isProduction
// })

export const init = () => {
if (typeof window === 'undefined') return
if (typeof window === 'undefined') {
return
}
let fired = false
const loadAnalyticsScript = () => {
if (!fired) {
Expand All @@ -20,12 +18,10 @@ export const init = () => {

window.addEventListener('mousemove', loadAnalyticsScript, { once: true })
window.addEventListener('touchstart', loadAnalyticsScript, { once: true })
window.addEventListener('touchmove', loadAnalyticsScript, { once: true })
window.addEventListener('touchend', loadAnalyticsScript, { once: true })
}

export const sendEvent = (name: string) => ga4.event('screen_view', {
app_name: 'ErbilCarRent',
app_name: 'movinin',
screen_name: name,
})

Expand Down

0 comments on commit 0108016

Please sign in to comment.