function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
krish4ukrish4u 

How to capture IP address in the web to lead form

Hi All,

I want to capture the IP address of the system in the web to Lead form. please suggest.
Vinit_KumarVinit_Kumar
What kind of page you are using for web to lead.Is it a standard HTML page or VF page ??
krish4ukrish4u
It is a standard HTML page.
Vinit_KumarVinit_Kumar
I am afraid you won't be able to track IP address in HTML page.

As a workaround,you should create a hidden field which would stroe the IP addree using JS function in your HTML page and post it along with your web - to lead request.

So,you should be looking something like below :-

<script language="javascript">

var ip = '<!--#echo var="REMOTE_ADDR"-->'

function ipval() {
document.myform.ipaddr.value=ip;
}
window.onload=ipval
</script>

<form method="post" action="" name="myform">
  <input type="hidden" name="ipaddr" readonly>
</form>

If this helps,please mark it as best answer to help others :)
krish4ukrish4u
Hi ,

Thank you for suggestion.but the script is not executing when the form is load.

any suggestions..?

<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">

<!--  ----------------------------------------------------------------------  -->
<!--  NOTE: Please add the following <FORM> element to your page.             -->
<!--  ----------------------------------------------------------------------  -->

<script language="javascript" type="text/javascript">

function ipval() {
alert("ippp");

var ip = '<!--#echo var="REMOTE_ADDR"-->'
document.myform.ipaddr.value=ip;
}
window.onload=ipval;
</script>

<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST" name="myform">
<input  id="ipaddr" maxlength="255" name="ipaddr" size="20" type="hidden" /><br>
<input type="submit" name="submit">

</form>