Add Query Parameters to Links in HTML
npm install link-painter
const queryParams = {
utm_source: 'newsletter',
utm_medium: 'link',
utm_campaign: 'link-painter'
};
const html = fs.createReadStream('./sample.html', 'utf-8');
const result = await getStream(html.pipe(new LinkPainter('my.example.com', queryParams)));
yields:
<!DOCTYPE html>
<html>
<head></head>
<body>
<div><a href="https://my.example.com/?utm_source=newsletter&utm_medium=link&utm_campaign=link-painter">click me</a></div>
<div><a href="https://google.com">or me</a></div>
</body>
</html>