Setting tracking cookie on client side vs server side?

Someone asked on Stack Overflow:

We want to set tracking cookie to check how many users we are getting through various marketing campaigns. On each campaign URL of our website, we add following query string parameters:- utm_source, utm_medium and utm_campaign.

Sample URL:- https://example.com/?utm_source=facebook&utm_medium=cpc&utm_campaign=jan

Anytime, we get request from any URL on our server, we check:

  1. If url has utm_* parameters, we save those in the cookie.
  2. If there’s no such utm_* parameters in the url and If referer host is our website i.e. https://example.com/, we save that in cookie for 6 months.
  3. If there’s no such utm_* parameters in the url and referer is one of search engine, we save search engine name in cookie.

and we have few more similar conditions.

Should we write this logic on server side (C#) OR Client side(javascript)?

I posted the following answer, which was chosen as the accepted answer and received 1 upvote:

Technically you can do it on either end; but in reality, you might have slightly better luck with a server side approach as it will be harder for browsers to get around (either they accept cookies or not). Things like noscript and adblockers could interfere with a client side implementation.

Additionally, if you do things server side, you could store that information along with a thumb print of the browser in a database and compare against that for future visits. That would work even if cookies are being blocked/cleared.


Originally posted on Stack Overflow — 1 upvotes (accepted answer). Licensed under CC BY-SA.

signed letter b

Dad. Geek. Gamer. Software developer. Cloud user. Old Car enthusiast.  Blogger.


Top Posts


profile for Nate on Stack Exchange, a network of free, community-driven Q&A sites
a proud member of the blue team of 512KB club
Thoughts, opinions, and ideas shared here are my own. © 2026 Nate Bross.