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"