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

astro-gtm-lite

v1.0.1

Published

Astro v6 with ViewTransition GTM integration. Lightweight Google Tag Manager, zero-config.

Readme

astro-gtm-lite

A zero-component Astro integration for Google Tag Manager (GTM).

Easily inject Google Tag Manager snippets into your Astro site. Supports Astro v4, v5, and v6. Works seamlessly with View Transitions (clientRouter).

Instead of manually adding GTM <script> and <noscript> tags to every page, astro-gtm-lite hooks into Astro's build pipeline and injects the official Google Tag Manager snippets automatically — no layout edits required.


Install

npm install astro-gtm-lite

Usage — Integration (recommended)

Add it once in astro.config.mjs and forget about it:

import { defineConfig } from "astro/config";
import gtm from "astro-gtm-lite";

export default defineConfig({
  integrations: [
    gtm({
      id: "GTM-XXXXXX",
    }),
  ],
});

The script is injected automatically into every page — no layout edits required.

Note: GTM is disabled during astro dev by default. Set devMode: true if you want to test GTM in development.

Astro View Transitions

astro-gtm-lite works seamlessly with and without Astro View Transitions.

On each client-side navigation, a virtualPageview event is pushed to dataLayer with the updated page path and title. The astro:after-swap event is used, which fires immediately after the DOM is swapped — perfect for analytics tracking.

To track these virtual page views in GTM, create a Custom Event trigger with event name virtualPageview, and use Data Layer Variables for virtualPagePath and virtualPageTitle to populate your GA4 / Universal Analytics tags.

Options

| Option | Type | Default | Description | | --------------- | --------- | ------------------------------------ | -------------------------------------- | | id | string | required | Your GTM container ID (GTM-XXXXXX) | | enable | boolean | true | Globally toggle GTM injection on/off | | devMode | boolean | false | Inject snippets during astro dev | | dataLayerName | string | "dataLayer" | Rename the global dataLayer variable | | domain | string | "https://www.googletagmanager.com" | Self-hosting or proxy domain |

Validation

  • id is strictly validated and must match the pattern GTM-XXXXXX (alphanumeric suffix, case-insensitive).
  • domain must be a valid URL with http: or https: protocol.

Usage — Component (optional)

If you prefer the classic component approach, import it directly:

---
import Gtm from "astro-gtm-lite/component";
---

<head>
  <Gtm id="GTM-XXXXXX" />
</head>

You can also conditionally disable it:

<Gtm id="GTM-XXXXXX" enable={false} />

License

MIT © Al Murad Uzzaman