The d8a web tracker provides a GA4 gtag-style API that sends GA4 gtag-compatible requests directly to a d8a collector.
npm install @d8a-tech/wtThe d8a web tracker provides a GA4 gtag-style API that sends GA4 gtag-compatible requests directly to a d8a collector.
The script-tag bundle auto-installs on load and supports optional src query parameters:
- ?l=: d8a queue name (data layer)
- ?g=: d8a global function name
- ?gl=: gtag/GTM consent queue name (defaults to dataLayer)
``html`
`bash`
npm install @d8a-tech/wt
`javascript
import { installD8a } from "@d8a-tech/wt";
// Optional overrides:
// - dataLayerName: d8a queue name (defaults to "d8aLayer")
// - globalName: d8a global function name (defaults to "d8a")
// - gtagDataLayerName: gtag/GTM consent queue name (defaults to "dataLayer")
installD8a();
const d8a = window.d8a;
if (!d8a) throw new Error("d8a is not installed");
d8a("js", new Date());
d8a("config", "
server_container_url: "https://global.t.d8a.tech/
});
`
When the same key is provided in multiple places, we resolve values as:
- Event params > config params > set params > browser defaults
- Runtime source is ESM JavaScript in src/ and types are shipped in index.d.ts.tsx
- Tests use (Node test runner compatibility):
`bash`
cd js/web-tracker
npm test
This package can produce a single browser bundle:
- dist/wt.min.js: Script-tag bundle (auto-installs on load)dist/index.min.mjs
- : ESM bundle
Build:
`bash`
cd js/web-tracker
npm install
npm run build
The example/ directory contains two pages to quickly validate behavior in a browser:
- example/index.html: dev/local setup (served by Vite; imports from ../src/ and calls installD8a()).example/prod.html
- : production-like setup (loads ../dist/wt.min.js, which auto-installs on load).
Run:
`bash`
cd js/web-tracker
npm install
npm run dev
Then open the printed URL (Vite will serve example/index.html as /).
Run:
`bash`
cd js/web-tracker
npm install
npm run build
python3 -m http.server 8080
Then open:
- http://127.0.0.1:8080/example/prod.html`