Skip to content

Commit

Permalink
docs: show full event forwarding example (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann authored Aug 2, 2023
1 parent c9be0a1 commit 1980589
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions docs/forwarding-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ Because GTM and Facebook Pixel objects are added immediately in the `<head>` by

However, since GTM and Facebook Pixel were actually loaded in the web worker, then we need to forward these calls. The `forward` config is used to set which `window` variables should be patched and forwarded on. The forward string value is of the function to call, and since GTM is pushing to an array, the function to call is `dataLayer.push`.

```json
{
"forward": ["dataLayer.push", "fbq"]
}
```js
<script>
partytown = {
forward: ['dataLayer.push', 'fbq']
};
</script>
```

Notice the forward configs are just strings, not actual objects. We're using strings here so we can easily serialize what service variable was called, along with the function argument values. When the web worker receives the information, it then knows how to correctly apply the call and arguments that were fired from the main thread.
Expand Down

1 comment on commit 1980589

@vercel
Copy link

@vercel vercel bot commented on 1980589 Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.