Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for Google Tag Assistent (Google Tag Manager preview)

See original GitHub issue

When using Google Tag Assistent to test a Proxytown implementation of Google Tag Manager, it fails to connect: Screenshot 2022-02-11 at 16 01 04 At first there were some CORS errors for the domain. After proxying those I can see the iframe getting added to the page, but it fails to load and some Partytown error occurs:

Screenshot 2022-02-11 at 16 07 01

In the page’s <head> I can see the following scripts:

<script type="text/partytown-x" src="http://localhost:3003/~partytownproxy/google-analytics/analytics.js" data-ptsrc="" data-ptid="351043767"></script>
<script type="text/partytown-x" src="http://localhost:3003/~partytownproxy/googletagmanager/gtag/js" data-ptsrc=";l=dataLayer&amp;cx=c" data-ptid="574473788"></script>
<script type="text/partytown" src="http://localhost:3003/~partytownproxy/googletagmanager/debug/bootstrap" data-ptsrc=";src=GTM&amp;cond=2&amp;gtm=2wg290" data-ptid="433709864" data-pterror="Error: Error finding instance &quot;1&quot; on window 2 (259405394)
    at sendToMain (http://localhost:3003/~partytown/debug/partytown-ww-sw.js:253:27)
    at queue (http://localhost:3003/~partytown/debug/partytown-ww-sw.js:226:20)
    at callMethod (http://localhost:3003/~partytown/debug/partytown-ww-sw.js:333:20)
    at Node.<anonymous> (http://localhost:3003/~partytown/debug/partytown-ww-sw.js:1338:24)
    at wc (;src=GTM&amp;cond=2&amp;gtm=2wg290:53:163)
    at eval (;src=GTM&amp;cond=2&amp;gtm=2wg290:66:331)
    at lc (;src=GTM&amp;cond=2&amp;gtm=2wg290:47:924)
    at Bc.start (;src=GTM&amp;cond=2&amp;gtm=2wg290:65:932)
    at eval (;src=GTM&amp;cond=2&amp;gtm=2wg290:70:1364)
    at Proxy.eval (;src=GTM&amp;cond=2&amp;gtm=2wg290:77:3)"></script>

And just before the </body>:

<iframe src="about:blank" class="__TAG_ASSISTANT_BADGE" frameborder="0" style="border: 0 !important; bottom: 24px !important; border-radius: 8px !important; box-shadow: 0 3px 5px -1px rgb(0 0 0 / 20%), 0 5px 8px 0 rgb(0 0 0 / 14%), 0 1px 14px 0 rgb(0 0 0 / 12%) !important; clip: initial !important; display: inline !important; height: 200px !important; left: auto !important; margin: 0 !important; max-width: 95% !important; opacity: 1 !important; padding: 0 !important; position: fixed !important; right: 24px !important; top: auto !important; visibility: visible !important; width: 450px !important; z-index: 2147483647 !important;" data-ptwindow="259405394"></iframe>

When switching back to the default GTM implementation (without Partytown), everything works as expected.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:12
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

tarponjargoncommented, Mar 17, 2022

This helps me get passed the CORs issue but I end up with these errors in the console after the timeout and I can’t seem to identify what I may need to forward to the main thread.

Yeah I got to the same point. the c.Postmessage is not a function error is repeated every second.

To make sure it’s not a disallowing the POST method I tried adding:

headers[“Access-Control-Allow-Origin”] = “*”; headers[“Access-Control-Allow-Methods”] = “GET,POST,HEAD,OPTIONS”;

To my reverse proxy to… And that doesn’t seem to be the issue.

There’s a partytown JS error that precedes the postMessage error. I ran partytown in debug mode and here’s the console output (in case it’s helpful to anybody).

The solution I ultimately arrived at is to set a query param like ?no_partytown=1 that if true, suppresses type="text/partytown" on the gtm script tag.

Screen Shot 2022-03-17 at 3 54 56 PM

slawekkolodziejcommented, Apr 7, 2022

I played with integrating tag assistant here:

I wrote a document with what I’ve found:

The implementation is not finished yet. It’s rather at early stage / POC. There are some missing parts and the implementation is definitely not production ready.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Preview and debug containers - Tag Manager Help
Google Tag Manager's preview and debug mode allows you to browse a site on which your container code is implemented as if the...
Read more >
Google Tag Manager Preview Mode - The Guide (2022)
A comprehensive guide on how to use the Google Tag Manager Preview mode (a.k.a. Google Tag Manager Debug mode) and catch errors faster....
Read more >
Tag Assistant Preview Mode In Google Tag Manager
Your favorite tagging platform, Google Tag Manager, now comes equipped with a completely revamped preview mode experience.
Read more >
Google Tag Assistant
Google Tag Assistant (Legacy) is a free Chrome extension that helps you make sure your Google tags such as Google Analytics, Google Tag...
Read more >
Google Tag Assistant
Deploy tags in Google Tag Manager easily and safely with the Community Template Gallery.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found