I have developed a simple registration page and given this page access to users through a force.com site. How can I store the visiting user's IP address in Salesforce?

1 Answer 1


Following may help:

String clientIP = ApexPages.currentPage().getHeaders().get('True-Client-IP');
if(clientIP == null || clientIP == ''){
    clientIP = ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP');
  • Hi San Tosh, Thank You for your help, it's woking fine. i have another question based on IP Address how we can get the Address (Street, City ,Country) information. Please help on this. i Relly Appreciate your help Sep 9, 2015 at 12:21
  • This can only be done by external API. you could use latitude and longitude for finding this. Pass the data to Google Maps API and it returns the address.
    – ipradhansk
    Sep 10, 2015 at 2:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.