Skip to content

Commit

Permalink
run analytics in prod - not dev
Browse files Browse the repository at this point in the history
  • Loading branch information
marcolarosa committed Jun 14, 2024
1 parent dac758f commit d34c30f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { defineConfig } from "vitepress";
import { sidebar } from "../sidebar-menu.js";

const GTAG = process.env.NODE_ENV !== "development" ? "G-GC2FXLTHYR" : undefined;

// https://vitepress.dev/reference/site-config
export default defineConfig({
title: "Describo",
Expand Down Expand Up @@ -36,11 +38,11 @@ export default defineConfig({
content: "Dr Marco La Rosa (https://marcolarosa.github.io/)",
},
],
["script", { async: "", src: "https://www.googletagmanager.com/gtag/js?id=G-GC2FXLTHYR" }],
["script", { async: "", src: `https://www.googletagmanager.com/gtag/js?id=${GTAG}` }],
[
"script",
{},
"window.dataLayer = window.dataLayer || [];\nfunction gtag(){dataLayer.push(arguments);}\ngtag('js', new Date());\ngtag('config', 'G-GC2FXLTHYR');",
`window.dataLayer = window.dataLayer || [];\nfunction gtag(){dataLayer.push(arguments);}\ngtag('js', new Date());\ngtag('config', '${GTAG}');`,
],
[
"script",
Expand Down

0 comments on commit d34c30f

Please sign in to comment.