Skip to content

Commit

Permalink
🔨 fix ga script won't include in dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Nismit committed May 16, 2024
1 parent 1240d08 commit 244a706
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
27 changes: 14 additions & 13 deletions app/routes/_renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,21 @@ export default jsxRenderer(({ children, title, post }) => {
}
})();
</script>
<script
async
src="https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}"
></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "${GA_TRACKING_ID}");
</script>
`}
{import.meta.env.MODE !== "development" &&
html` <script
async
src="https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}"
></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "${GA_TRACKING_ID}");
</script>`}
<Script src="/app/client.ts" async />
<Style />
</head>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"type": "module",
"scripts": {
"dev": "npm run prebuild && vite",
"dev": "npm run prebuild && vite dev",
"build": "npm run prebuild && vite build --mode client && NODE_ENV='production' && vite build",
"prebuild": "node ./app/build.js",
"storybook": "storybook dev -p 6006",
Expand Down

0 comments on commit 244a706

Please sign in to comment.