From 3f71cd54d4393cbe91f66dc8d978fb962bdd30e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrea=20Vel=C3=A1squez?= <33611986+a4vg@users.noreply.github.com> Date: Mon, 18 Mar 2024 11:59:02 -0500 Subject: [PATCH] docs(SvelteKit): fix Google Tag Manager example --- docs/sveltekit.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/sveltekit.md b/docs/sveltekit.md index dac41049..b556f6f7 100644 --- a/docs/sveltekit.md +++ b/docs/sveltekit.md @@ -50,7 +50,11 @@ Adapting from [the HTML integration guide](https://partytown.builder.io/html) ## 3. Then add 3rd party scripts -This is where we use partytown to add those scripts (note `type="text/partytown"` below). This example shows Google Tag Manager. Putting it together with the previous changes, our `+layout.svelte` looks like: +This is where we use partytown to add those scripts (note `type="text/partytown"` below). If your script declares global functions or variables, make sure they are explicitly declared with `window` and forwarded to the web worker. + +This example shows Google Tag Manager. Note `window.gtag = function()` instead of `function gtag()`. + +Putting it together with the previous changes, our `+layout.svelte` looks like: ```svelte // src/routes/+layout.svelte @@ -65,7 +69,7 @@ This is where we use partytown to add those scripts (note `type="text/partytown" @@ -74,7 +78,7 @@ This is where we use partytown to add those scripts (note `type="text/partytown"