i’d like to implement some logic based on where is user coming from,
lets say if user is coming from TikTok – clicked on a link to my website, then i’d like to track it.
Yes, i know i could use specific link/query params for each channel, but i want to be as agnostic as i can.
I’m thinking of implementing a middleware, but what should i check for?
Something like:
function checkOrigin(req, res, next) {
if (req.originalUrl.includes('redirect-from-tiktok')) {
setCookie('channel', 'tiktok');
}
next();
}