npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@appsurify-testmap/google-custom-event-tracker

v0.9.4

Published

Lightweight DOM interaction tracker for GA4/gtag (click, input, keypress) with Vite bundling.

Readme

📦 Installation

NPM

npm install @appsurify-testmap/google-custom-event-tracker

Yarn

yarn add @appsurify-testmap/google-custom-event-tracker

PNPM

pnpm add @appsurify-testmap/google-custom-event-tracker

📚 Usage

ESM

import { initTracker } from "@appsurify-testmap/google-custom-event-tracker";

initTracker({
  send(payload) {
    gtag("event", "ui_event", payload);
  },
  debug: false, // Set to true for detailed console logging
});

CommonJS

const { initTracker } = require("@appsurify-testmap/google-custom-event-tracker");

initTracker({
  send: (payload) => gtag("event", "ui_event", payload),
});

🌐 CDN Usage (UMD)

You can include the library directly via a <script> tag.

jsDelivr

<script src="https://cdn.jsdelivr.net/npm/@appsurify-testmap/google-custom-event-tracker/dist/google-custom-event.umd.js"></script>

unpkg

<script src="https://unpkg.com/@appsurify-testmap/google-custom-event-tracker/dist/google-custom-event.umd.js"></script>

After loading the UMD bundle the global object is available as:

window.GoogleCustomEventTracker;

🚀 Quick Start with GA4 (gtag.js)

Add the standard GA4 snippet:

<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag() {
    dataLayer.push(arguments);
  }

  gtag("js", new Date());
  gtag("config", "G-XXXX");
</script>

Now include and initialize the tracker:

<script src="https://cdn.jsdelivr.net/npm/@appsurify-testmap/google-custom-event-tracker/dist/google-custom-event.umd.js"></script>
<script>
  window.GoogleCustomEvent.init({
    send(payload) {
      gtag("event", "ui_event", payload);
    },
  });
</script>

🏷 GTM Integration (dataLayer)

If your site uses Google Tag Manager:

<script src="https://cdn.jsdelivr.net/npm/@appsurify-testmap/google-custom-event-tracker/dist/google-custom-event.umd.js"></script>
<script>
  window.GoogleCustomEvent.init({
    send(payload) {
      window.dataLayer.push({
        event: "ui_event",
        ...payload,
      });
    },
  });
</script>

In GTM create a Custom Event Trigger with Event name: ui_event


🧪 What the Tracker Captures

On user interaction (click, input, etc.) the tracker sends:

{
  "type": "click",
  "tag": "button",
  "selector": "v1.0: body :: button[id=\"submit\",text=\"Submit\"]",
  "text": "Submit",
  "ts": 1737139231
}

The selector field uses SEQL (Semantic Element Query Language) format, which provides stable element identification that survives DOM restructuring and CSS changes.

Settings allow enabling/disabling:

initTracker({
  captureSelector: true,
  captureText: true,
  debug: false, // Enable debug logging
  seqlOptions: {}, // Options for SEQL selector generation
});

🧩 TypeScript Support

The package ships with full declaration files:

dist/google-custom-event-tracker.d.ts

TypeScript will automatically pick up the types:

import type { TrackerOptions, TrackerEvent } from "@appsurify-testmap/google-custom-event-tracker";

🔐 Browser Support

The UMD build works in:

  • Chrome
  • Firefox
  • Safari
  • Edge

ESM works in all modern browsers and bundlers.


🐛 Debug Mode

Enable debug mode to see detailed logging in the console:

initTracker({
  debug: true,
  send(payload) {
    gtag("event", "ui_event", payload);
  },
});

When debug mode is enabled, the tracker will log:

  • All captured events with full payload details
  • Errors during selector generation with element references
  • Warnings when selector generation fails

This is useful for troubleshooting and understanding what data is being captured.


📄 License

MIT