johannschopplich / nuxt-gtag

🔸 Google Tag integration for Nuxt: Google Analytics, Google Ads and more

Home Page:https://developers.google.com/tag-platform/gtagjs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No data collected

breizhwave opened this issue · comments

Environment

{
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"devDependencies": {
"nuxt": "^3.2.3",
"primeflex": "3.2.1",
"primeicons": "5.0.0",
"primevue": "^3.25.0"
},
"dependencies": {
"@pinia/nuxt": "^0.4.4",
"bootstrap": "^5.2.3",
"mixpanel-browser": "^2.47.0",
"nuxt-gtag": "^0.5.7",
"sass": "^1.56.1"
}
}

Reproduction

used both yarn and pnpm and yarn do to add nuxt-gtag, front renders the gtag configuration, but does not add page view script. tried to add view script manually but still no change within analytics, no data collected, source here https://calculatrices-klosup-lrm.fr/calculatrices-2023/cloture-horizontale-simple/

window.NUXT={serverRendered:false,config:{public:{gtag:{id:"G-QxxxxxxxY",config:{},initialConsent:true,loadingStrategy:"defer"}}

Describe the bug

not collecting data at all (similar to #11, except won't collect on other pages)

Additional context

No response

Logs

No response

just needed to add page view event

gtag('event', 'page_view', {
  page_location: window.location.href,
  page_path: useRoute().path,
  page_title: document.title,
})

Have you ensured, that the Enhanced measurement feature is enabled to allow GA4 to automatically track page views in your Single Page Application?

To enable this feature, go to your Google Analytics 4 account, then navigate to "Admin" > "Data Streams" > "Web" > "Enhanced measurement settings." In this section, make sure the "Page views" toggle is enabled. Enabling the "Page views" toggle allows GA4 to track page changes based on browser history events in your Single Page Application.

thks did not know. I actually prefer to use the code because i'm on SSG and not couting everything

thks anyway clsing

Glad to hear you found a solution. 🙂

just needed to add page view event

gtag('event', 'page_view', {
  page_location: window.location.href,
  page_path: useRoute().path,
  page_title: document.title,
})

Do we need to add this page_view event if the advanced tracking is enabled? Or only if it's not?

You need this only if you have advanced tracking disabled.