How GTM & gtag use Service Workers for analytics

Written by

Giovani Ortolani Barbosa

Published Oct 10, 2025 comments

What are Service Workers?

How GTM and gtag use Service Workers

Communication flow

gtag/GTM ↔ iframe (about:blank) ↔ iframe (sw_iframe.html) ↔ sw.js (Service Worker)
iframes in the DevTools Elements tab

1. Service Worker loaded from sGTM first-party domain

2. Service Worker loaded from googletagmanager.com domain

The .delegate method

k.delegate = function (a, b, c) { this.getState() !== 2 ? (this.H.C( // Path 1: Not Ready - Sends event from main page. this.C, { state: this.getState(), hg: this.initTime, ng: Math.round(Ab()) - this.initTime }, void 0, a.commandType ), c({ // Call the failure callback failureType: this.C })) : this.N.wo(a, b, c); // Path 2: Ready - Sends events from Service Worker. };
StateMeaning

How to Check If Service Workers Are Being Used

1. DevTools Network Tab

Note:

Service Worker from sGTM first-party domain in DevTools Network tab
Service Worker from sGTM first-party domain in DevTools Network tab
Service Worker from googletagmanager.com domain in DevTools Network tab

2. DevTools Application Tab

Service Worker being served from the sGTM first-party domain
Service Worker being served from googletagmanager.com

3. DevTools Network Tab

Gear icons in DevTools Network tab

Why you don’t see some events in the Network Tab

  1. 1.
  2. 2.
  3. 3.

Conclusion

Want to switch to the server side?

Try for free

Written by

Giovani Ortolani Barbosa

Content writer

Giovani Ortolani Barbosa is an Integration Engineer at Stape who develops advanced Google Tag Manager templates, troubleshoots complex tracking issues, and specializes in server-side tagging.

Was this article helpful?

Comments

Turn better tracking into better marketing performance

Try for free