Data not collecting in SSG mode
noahps opened this issue ยท comments
First off, awesome plugin - so easy to install and get started!
I installed and configured with just the basic settings. Data instantly started collecting when running my site in development mode. However, when I use static site generation to render and publish a static site, data is not collecting on the output site.
Here's what my config looks like.
import i18nConfig from './config/i18nConfig'
import svgLoader from 'vite-svg-loader'
export default defineNuxtConfig({
app: {
head: {
link: [{ rel: "icon", href: "/favicon.ico", sizes: "32x32" }],
link: [{ rel: "icon", href: "/icon.svg", type: "image/svg+xml" }],
link: [{ rel: "apple-touch-icon", href: "/apple-touch-icon.png" }],
link: [{ rel: "manifest", href: "/manifest.webmanifest" }],
},
},
build: {
transpile: [
"markdown-it",
"vuetify",
],
},
css: [
'vuetify/lib/styles/main.sass',
],
// debug: true,
experimental: {
// important!! inlineSSRStyles must be false to allow for custom styles to be applied to vuetify components
// Vuetify configFile styles and Nuxt inlineSSRStyles are incompatible
inlineSSRStyles: false,
payloadExtraction: process.env.APP_USE_SSR == 'TRUE' ? true : false,
},
hooks: {
// if needed, add hook for pre-rendering routes that crawler can't find
},
gtag: {
id: 'G-xxxxxxx',
},
i18n: {
/* module options */
customRoutes: 'config',
...i18nConfig,
lazy: false,
langDir: "locales",
strategy: "prefix_and_default",
defaultLocale: "en",
vueI18n: './config/nuxtVuei18nConfig',
},
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
'@nuxtjs/i18n',
'@pinia/nuxt',
'@vueuse/nuxt',
'nuxt-gtag',
'vuetify-nuxt-module',
],
nitro: {
baseURL: "",
prerender: {
crawlLinks: false,
},
static: process.env.APP_USE_SSR == 'TRUE' ? true : false,
},
runtimeConfig: {
public: {
awsSettings: require(`.${process.env.APP_CONFIG_ROOT}/aws-exports.js`),
ssr: process.env.APP_USE_SSR == 'TRUE' ? true : false,
},
},
sourcemap: {
server: true,
client: true,
},
// conditionally set ssr setting depending on environment
ssr: process.env.APP_USE_SSR == 'TRUE' ? true : false,
vuetify: {
moduleOptions: {
/* module specific options */
styles: { configFile: '/settings.scss' }
},
vuetifyOptions: './vuetify.config.ts',
},
vite: {
plugins: [
svgLoader({}),
],
},
})
For my generated site, the environment variable APP_USE_SSR
is set to TRUE
Is there something I need to configure differently in order for tracking to take place with SSG rendered pages? Do I need to turn off SSR for static generated pages?
Thanks for any help!
Thanks for the report. Can you please provide a reproducible example? Please use a template below to create a minimal reproduction:
๐ https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz
๐ https://codesandbox.io/p/github/nuxt/starter/v3-codesandbox
Thanks in advance!
Ok, will do. I wasn't sure if there was something obvious I was missing that makes this not a bug but just not seeing something in the docs. I'll put together a reproduction.
It turns out the issue was on my end. Apologies for submitting the ticket prematurely! Thanks for a great package!
@noahps Thanks a lot for the feedback. ๐