You should be able to inherit the System.Net class in your macro and access Request.Uri from there. I have not tried it, but that should work.
If you are doing this in a transformation, I would probably not do a macro at all but instead just do some JavaScript or jQuery to get the referrer...Macors are good but have a performance hit to them. Might not be a big deal, but neither would,the client script.
Lastly, I would explore the CMS.Helper class, I feel like I have seen a function to be able to grab this, but I am away from my computer right now. Others might chime in.