Stape.io with Partytown?

Hey there!

I’m working to optimize site speed as much as possible. While the sGTM integration with a custom loader through Stape.io is one aspect, there are still many pixels and scripts that can’t be moved to the sGTM container just yet, and could impact site speed.

I’m considering implementing a lazy-loading library called PartyTown to implement a web-worker for our GTM script (potentially moving our pixels out of GTM so we can move them through PartyTown separately if that would help).

I’m curious how this may work with the custom loader that you offer? Do you think adding PartyTown could help with load times? Do you think this would be a worthwhile implementation if we already have your custom loader implemented?

Hey Megan,

From technical perspective, there shouldn’t be any issues with our custom loader.

From measurement perspective we would advise against delaying container load, there is a reason Google asks you to load it as soon as possible, in the wild you may end up with some UTMs / click-ids lost because user could already leave the page by that time.

1 Like

I’ve tested this out with the custom loader and I have encountered a few challenges:

  1. The web container preview mode doesn’t work.
  2. The web container doesn’t seem to detect events that aren’t page views (tried using preview mode to debug what’s happening - but again, not working).
  3. I get a CORS error in the console for a request to the server container (although the page_view events seem to be tracking just fine).

Happy to share the URL/more details if it would be useful.

The custom loader does not affect the preview or events in any way; it is simply a method for loading JS.
Your problem is definitely related to CORS, which is causing the container to work incorrectly or not load at all. You need to add exceptions to CORS for this to work correctly.