Is this not working? This will enter the URL that is currently entered in the Sites applicatin under domain name property. So if you currently have "localhost" in there, it will return "localhost". If you have www.domain.com, that is what it will return.