Developing a tracking pixel

I am trying to build a pixel that would track the current URL the user is on when they visit. I can use either JS (preferred) or a 1×1 image pixel. With JS I am assuming that I’d need to run an AJAX