Skip to content

Commit

Permalink
Update Partytown (TraceMachina#1467)
Browse files Browse the repository at this point in the history
Add partytown config to be able to push analytics into the data layer
  • Loading branch information
MarcusSorealheis authored Nov 7, 2024
1 parent cb9d441 commit 3fbc273
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion web/platform/astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ export default defineConfig({
}),
starlight(starlightConfig),
sitemap(),
partytown(),
partytown({
config: {
forward: ["dataLayer.push"],
},
}),
],
markdown: {
rehypePlugins: [
Expand Down
7 changes: 7 additions & 0 deletions web/platform/src/thirdParty/GoogleTagManager.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ const measurementId = props.measurementId
type='text/partytown'
src={`https://www.googletagmanager.com/gtag/js?id=${measurementId}`}>
</script>
<script type="text/partytown">
window.dataLayer = window.dataLayer || [];
window.gtag = function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', measurementId);
</script>

0 comments on commit 3fbc273

Please sign in to comment.