Blog Sending logs and traces

Install ZipLogger with Google Tag Manager

Some sites have no build step. Others have one, but the only thing you are allowed to change is the Tag Manager container. Either way, npm install is not an option.

This post shows how to load the ZipLogger browser SDK from a Google Tag Manager Custom HTML tag. You get uncaught JavaScript errors and unhandled promise rejections reported to ZipLogger, and your other tags can send events. The payloads below are real output from this tag, captured in a browser against a local test server.

Make a browser key

Anything a browser runs can be read by anyone who opens devtools, so give the tag its own key. In ZipLogger, go to Settings → API keys, give the key a name, and leave Can read data unticked. That makes it an ingest key: it can send telemetry but cannot read anything back. You can revoke it without touching your backend keys.

Add the tag

In Google Tag Manager:

  1. Choose Tags → New → Tag Configuration → Custom HTML.
  2. Paste the tag below and replace YOUR_BROWSER_API_KEY with your key.
  3. Under Triggering, pick Initialization - All Pages. That trigger fires before your other tags.
  4. Save, check it in Preview, then Submit to publish the container.
<script>
(function (w, d) {
  if (w.ziplogger) return;

  // Until the SDK has loaded, calls are kept here and replayed afterwards.
  var calls = [];
  var stub = { _calls: calls };
  var names = ['track', 'identify', 'log', 'captureError', 'reset'];
  function queue(name) {
    stub[name] = function () { calls.push([name, arguments]); };
  }
  for (var i = 0; i < names.length; i++) queue(names[i]);
  w.ziplogger = stub;

  // The SDK is an ES module, so it is loaded by a module script.
  var s = d.createElement('script');
  s.type = 'module';
  s.text = [
    "import { ZipLoggerBrowser } from 'https://cdn.jsdelivr.net/npm/@ziplogger/[email protected]/index.js';",
    "var queued = window.ziplogger._calls;",
    "var zl = new ZipLoggerBrowser({",
    "  endpoint: 'https://app.ziplogger.ai',",
    "  apiKey: 'YOUR_BROWSER_API_KEY'",
    "});",
    "zl.captureGlobalErrors();",
    "window.ziplogger = zl;",
    "queued.forEach(function (c) { zl[c[0]].apply(zl, c[1]); });"
  ].join('\n');
  d.head.appendChild(s);
})(window, document);
</script>

The tag does three things. It puts a small stand-in at window.ziplogger that remembers calls. It adds a module script that imports the SDK, creates the client and starts listening for errors. When the SDK has loaded, the real client replaces the stand-in and the remembered calls are replayed.

The SDK is published as an ES module, with no single-file script build, which is why the tag writes a module script and does not use a plain <script src>. The outer code is plain old JavaScript on purpose, so the Tag Manager editor has nothing to complain about.

The options inside new ZipLoggerBrowser({ ... }) are the same ones you would pass in code. source defaults to the page's hostname and environment defaults to production. To change them, add a line inside the quotes, for example " source: 'storefront',".

What an error looks like

With the tag live, a page that reads .items off a null cart sends this:

{
  "timestamp": "2026-11-28T16:43:15.179Z",
  "severity": "error",
  "message": "Uncaught TypeError: Cannot read properties of null (reading 'items')",
  "source": "shop.example.com",
  "stackTrace": "TypeError: Cannot read properties of null (reading 'items')\n    at https://shop.example.com/checkout:17:33",
  "fields": {
    "environment": "production",
    "file": "https://shop.example.com/checkout",
    "line": 17,
    "column": 33,
    "handler": "window.onerror",
    "url": "https://shop.example.com/checkout",
    "userAgent": "Mozilla/5.0 (...)",
    "exceptionType": "TypeError",
    "exceptionMessage": "Cannot read properties of null (reading 'items')"
  }
}

It is grouped on the Issues page with every repeat of the same error, and it is also a log line on the Search page. The JavaScript error tracking post covers what you can do with it from there.

Send a dataLayer event to ZipLogger

If your site already pushes events to the dataLayer, you can keep a copy of them in ZipLogger without touching the site. Add a second Custom HTML tag:

<script>
  if (window.ziplogger) {
    window.ziplogger.track({{Event}}, { path: {{Page Path}} });
  }
</script>

Give it a Custom Event trigger with the name of the dataLayer event, for example purchase. {{Event}} and {{Page Path}} are built-in Tag Manager variables. Tag Manager replaces them with their values before the script runs, so they are written without quotes.

A purchase event then arrives like this:

{
  "type": "track",
  "name": "purchase",
  "timestamp": "2026-11-28T16:43:13.494Z",
  "anonymousId": "anon_28e301f00a040a95d493",
  "sessionId": "sess_9b0cf88049479cebf91b",
  "environment": "production",
  "insertId": "fb06663639bd818312a1020f",
  "properties": { "path": "/checkout" },
  "url": "https://shop.example.com/checkout",
  "page": "/checkout"
}

To send more, add properties from your own Data Layer Variables, for example { path: {{Page Path}}, value: {{DLV - value}} }, where DLV - value is a variable you created in the container.

The SDK gives each visitor an anonymous id, kept in localStorage under zl_anon, and a session id per tab. When you know who the visitor is, call window.ziplogger.identify('user_42') from a tag that fires after sign-in. That links what the browser did anonymously to the account.

If the event fires before the SDK has finished loading, the call is queued and sent once it has. That is what the stand-in is for.

What it does not do

  • Errors before the tag runs are not reported. Tag Manager loads after the page starts, and the SDK loads after that. Installing from npm and calling captureGlobalErrors() first thing in your own code sees errors this tag misses.
  • No session replay and no RUM. Both import other packages (@rrweb/record and web-vitals) that a browser cannot resolve without a bundler. Use the npm install for those.
  • The SDK comes from a third party. The tag loads one file from jsDelivr, pinned to version 0.8.0, so it does not change until you edit the tag. If you do not want that request, copy index.js from the npm package to your own site and change the URL. It is one file with no imports.
  • Stack traces stay minified. Source maps are matched by release, and a release written by hand into a tag goes out of date on your next deploy. If you need readable frames, set release from your build with the npm install. See source maps.
  • A blocker that stops Tag Manager stops this too. Visitors whose browser blocks googletagmanager.com send nothing.
  • Content Security Policy. If your site sends one, allow https://cdn.jsdelivr.net in script-src and https://app.ziplogger.ai in connect-src.
  • Consent is yours to wire up. The tag fires on whatever trigger you give it. If your site asks before setting analytics storage, use your consent trigger, or the tag's Consent Settings, the same way you do for your other tags.

Errors and events count toward your plan like any others; see pricing.

The same steps, without the commentary, are in the Google Tag Manager docs, and the full option list is in the browser docs. To try it, create a free workspace, make an ingest key, and paste the tag.

JavaScript and React error tracking

Catch uncaught JavaScript errors, promise rejections and React render errors with @ziplogger/browser. Real payloads, plus what it does not do.

Release health: crash-free sessions per release

See crash-free sessions, crash-free users and adoption for each release, from Sentry SDKs or ZipLogger's own SDKs, and get alerted when a release crashes more.

Use the Sentry SDK with ZipLogger

Keep your Sentry SDK and send its errors, traces and logs to ZipLogger by changing the DSN. Node, browser and Python setups, and what is dropped.

Try it on your own logs

There is a free plan and no sales call. Install an SDK, send a few log lines, and search them.