Skip to content

Commit

Permalink
fix env var inclusion in ga tag
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinsgoodman committed Apr 5, 2024
1 parent adcd645 commit 4701c1c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/landing-site/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { landingBody } from '@framework/system/src/styles/layouts.css'
import { SocialMetaTags } from '../../../site/src/components/social-meta-tags'
const contributorsData = await getContributorsData()
const GA_TAG_ID = import.meta.env.VITE_GOOGLE_ANALYTICS
---

<!doctype html>
Expand All @@ -37,11 +38,11 @@ const contributorsData = await getContributorsData()
async
src={`https://www.googletagmanager.com/gtag/js?id=${import.meta.env.VITE_GOOGLE_ANALYTICS}`}>
</script>
<script is:inline>
<script is:inline define:vars={{ GA_TAG_ID }}>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${import.meta.env.VITE_GOOGLE_ANALYTICS}');
gtag('config', GA_TAG_ID);
</script>
)
}
Expand Down
6 changes: 4 additions & 2 deletions packages/site/src/layouts/base.astro
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const navData = searchData.map((o) => pick(o, ['name', 'subCategories']))
const themeClass = themes[
`${import.meta.env.VITE_FRAMEWORK}Theme` as keyof typeof themes
] as string
const GA_TAG_ID = import.meta.env.VITE_GOOGLE_ANALYTICS
---

<!doctype html>
Expand Down Expand Up @@ -53,11 +55,11 @@ const themeClass = themes[
async
src={`https://www.googletagmanager.com/gtag/js?id=${import.meta.env.VITE_GOOGLE_ANALYTICS}`}>
</script>
<script is:inline>
<script is:inline define:vars={{ GA_TAG_ID }}>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${import.meta.env.VITE_GOOGLE_ANALYTICS}');
gtag('config', GA_TAG_ID);
</script>
)
}
Expand Down

0 comments on commit 4701c1c

Please sign in to comment.