From 5c112d174c80a8d40cc93556110f3eee9dec2935 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Thu, 6 Jul 2023 13:02:20 -0700 Subject: [PATCH] docs: show full event forwarding example --- docs/forwarding-events.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/forwarding-events.md b/docs/forwarding-events.md index 235aa990..c7c00e00 100644 --- a/docs/forwarding-events.md +++ b/docs/forwarding-events.md @@ -18,10 +18,12 @@ Because GTM and Facebook Pixel objects are added immediately in the `
` 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 + ``` 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.