BuilderIO / partytown

Relocate resource intensive third-party scripts off of the main thread and into a web worker. 🎉

Home Page:https://partytown.builder.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Experience with Partytown and Server Side Tagging?

j0Shi82 opened this issue · comments

Hey folks!

We recently adopted Partytown for a Shopify OS 2.0 shop and ran into some trouble integrating Partytown with our Tagging Server. One thing I quickly realized was that tracking cookies weren't set at all in the shop. document.cookie works fine, but cookies from the server get set by HTTP headers, which doesn't seem to work.

I did a little testing and apparently the issue is using XMLHttpRequest inside Web Workers, even if the withCredentials property is properly set. I could reproduce that cookies are neither send to, nor set by the server using XMLHttpRequest.withCredentials (which Google Analytics does for example).

The fetch-API doesn't have the same issue as long as the credentials-setting is included. I set up a small test site (it's a personal test site without proper consent management, so be warned) that checks on cookies using different Tagging-Methods. You can click the links at the top of the page to go through scenarios:

  • SGTM (Server Side Tagging)
  • SGTM & PT (Server Side Tagging inside Partytown)
  • GTM (Client Side Tagging)
  • GTM & PT (Client Side Tagging inside Partytown)

I also included a TEST-COOKIE that gets set from a fetch-Request inside Partytown if you're using Server Side Tagging. You'll notice that all client cookies get properly set when using Client Side Tagging with or without Partytown. Server Side Tagging also works just fine without Partytown, but adding Partytown to the mix only sets the TEST-COOKIE from fetch but fails to set all the others from XMLHttpRequest.

Has anyone tested an implementation of Partytown and Server Side Tagging and is able to provide some insight?