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

@tribusdigital/emdash-tracking-scripts

v0.1.0

Published

Native EmDash plugin for injecting third-party tracking and analytics scripts (Google Tag Manager, GA4/gtag, Lead Forensics, and custom snippets) site-wide, with an admin-configurable settings screen.

Readme

@tribusdigital/emdash-tracking-scripts

CI License: MIT PRs welcome

A native EmDash CMS plugin that injects third-party tracking and analytics scripts — Google Tag Manager, GA4/gtag, Lead Forensics, and any other raw snippet — site-wide, with an admin-configurable settings screen so a non-technical SEO user can manage tracking IDs without a developer or a deploy.

Why a native plugin, not a registry install

Raw <script> injection into <head>/<body> is only available through EmDash's page:fragments hook, which is trusted-only and explicitly excluded from the sandboxed plugin registry. This package must be installed as a normal npm dependency of your site and wired into astro.config.mjs — it cannot be installed from inside the CMS admin's plugin browser.

Install

npm install @tribusdigital/emdash-tracking-scripts
// astro.config.mjs
import { trackingScriptsPlugin } from '@tribusdigital/emdash-tracking-scripts';
import emdash from 'emdash/astro';

export default defineConfig({
	integrations: [
		emdash({
			plugins: [trackingScriptsPlugin()],
			// ...your existing database/storage config
		}),
	],
});

Your site's layout must already render <EmDashHead>, <EmDashBodyStart>, and <EmDashBodyEnd> from emdash/ui (this is the standard EmDash site setup) — the plugin's fragments render through those.

Configure

Once installed and deployed, an Analytics & Tracking settings screen appears in the EmDash admin (auto-generated from the plugin's settings schema — no extra admin code to build or maintain). Available fields:

| Field | What it does | | --- | --- | | Enabled | Master on/off switch for every tracking script on the site. | | Google Tag Manager Container ID | e.g. GTM-XXXXXXX. Adds the standard GTM <script> in <head> and the <noscript> fallback at the start of <body>. | | Google Analytics 4 Measurement ID | e.g. G-XXXXXXXXXX. Only needed if loading GA4 directly rather than through GTM. Adds gtag.js plus the init snippet. | | Lead Forensics tracking snippet | Paste the full <script> snippet from your Lead Forensics account as-is. Rendered near the end of <body>. | | Custom <head> snippet | Any other raw HTML/script for <head> on every page. | | Custom end-of-<body> snippet | Any other raw HTML/script just before </body> on every page. |

Values are stored via EmDash's plugin settings API and take effect immediately — no rebuild or redeploy needed to change a tracking ID.

GTM and GA4 IDs are validated against their expected format (GTM-... / G-...) before being used; anything that doesn't match is silently skipped rather than emitted as a broken script tag. The Lead Forensics and custom snippet fields are rendered verbatim — they're plugin settings editable only by whoever has admin/plugin-settings access in your CMS, the same trust level as WordPress's "insert headers and footers" style plugins.

Development

npm install
npm test

index.mjs separates the pure fragment-building logic (buildFragments, resolveSettings) from the definePlugin() wiring, so the tracking-tag output is fully unit tested without needing a running EmDash instance.

Contributing

This plugin is deliberately kept small, dependency-free, and thoroughly tested so it stays trustworthy as trusted-authority code — that's also what makes it a good base to build on rather than reinvent. If it's missing an integration you need (a platform, a consent-mode toggle, per-page opt-out, etc.), we'd much rather have that as a PR here than see a dozen narrower forks. See CONTRIBUTING.md for the ground rules, and CODE_OF_CONDUCT.md for how we expect people to treat each other while doing it. Issues and PRs welcome.

License

MIT — see LICENSE. Free to use, fork, and build on.