1.0.7 • Published 8 years ago
link-tracker v1.0.7
link-tracker
A simple library for tracking link clicks.
Installation
npm install link-tracker
Usage
Link-tracker creates encoded links with a timestamp.
var linkTracker = require('link-tracker');
var trackedLink = linkTracker.encodeUrl('http://www.github.com');
var trackedLinkWithParams = linkTracker.encodeUrl('http://www.github.com', 'param1=value1¶m2=value2');
Link-tracker will then validate these links when clicked and respond with 302 redirect, a 400 if the link has been modified or 410 if the link has expired.
var linkTracker = require('link-tracker');
router.get('/url/*', function(req, res) {
linkTracker.url(req, res);
});
The error handler may also be customized with an error handler
var linkTracker = require('link-tracker');
router.get('/url/*', function(req, res) {
linkTracker.url(req, res, function(statusCode, originalLink) {
// handle the error here
});
});