tracking-params
v0.2.2
Published
Easily get and remove unwanted tracking parameters from URLs.
Downloads
25
Maintainers
Readme
Tracking Params
Easily get and remove unwanted tracking parameters from URLs.
This project was inspired by neat-url, but includes more functionality by returning detailed info along with the cleaned URL.
Installation
npm install tracking-params
Usage
const { cleanUrl, getTrackingData } = require('tracking-params');
const url = 'https://example.com?ok=ok';
const dirtyUrl = url + '&utm_term=term';
console.log(cleanUrl(url));
// 'https://example.com?ok=ok'
console.log(cleanUrl(dirtyUrl));
// 'https://example.com?ok=ok'
console.log(getTrackingData(url));
// {
// url: 'https://example.com?ok=ok',
// isDirty: false,
// trackingParams: [],
// cleanUrl: 'https://example.com?ok=ok'
// }
console.log(getTrackingData(dirtyUrl));
// {
// url: 'https://example.com?ok=ok&utm_term=term',
// isDirty: true,
// trackingParams: [
// { key: 'utm_term', value: 'term' }
// ],
// cleanUrl: 'https://example.com?ok=ok'
// }