ping-tracker
v0.3.4
Published
A simple and lightweight library for adding tracking to anchor elements (links).
Downloads
13
Maintainers
Readme
Ping Tracker
Ping Tracker is a tiny library that adds ping
attribute to all <a>
tags on the site with customizable list of URLs.
Features
- 🏓 Add
ping
attribute to all<a>
tags automatically - 👀 Watch for changes using
MutationObserver
to modify newly added links - 📝 Customize the content of the
ping
tag (list of URLs) - ⚡️ Tiny library (2.7kB minified, 1.2kB gzipped)
- 📭 No dependencies
- 🌳 Tree-shakeable
- 🔥 Written in TypeScript
Installation
npm i ping-tracker
Usage
import { PingTracker } from "ping-tracker";
const pt = new PingTracker("https://analytics.example.com");
// Or with options
const pt = new PingTracker("https://analytics.example.com", {
hrefToQuery: false,
onlyExternal: false,
watchDOM: true,
elementsToWatch: document.body,
});