Re: Collecting IP address once form is completed

Anonymous
Not applicable

Collecting IP address once form is completed

Hi,

Is there any way to collect a recipient's IP address once they have completed a Marketo form?

Thanks,
Nicole
Tags (1)
6 REPLIES 6
Anonymous
Not applicable

Re: Collecting IP address once form is completed

Marketo silently collects the IP address when a lead fills out a form.
That information is accessible through the Activity Log.
 
Assuming the IP is relevant for GeoLocation or user-defined activities, you can either use SOAP API to retrieve that information of add a JavaScript to save the IP and GeoLocation to custom fields.
 
The SOAP API call would be getLead or getMultipleLeads
 
getLeadActivity is also a good fit
 
You can then use syncLead or syncMultipleLeads to find the IP and location to custom fields
 
 
A small JavaScript allows to read and save that information in one go when the form is saved:
function myIP() {
    if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest();
    else xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 
    xmlhttp.open("GET","http://api.hostip.info/get_html.php",false);
    xmlhttp.send();
 
    hostipInfo = xmlhttp.responseText.split("\n");
 
    for (i=0; hostipInfo.length >= i; i++) {
        ipAddress = hostipInfo[i].split(":");
        if ( ipAddress[0] == "IP" ) return ipAddress[1];
    }
 
    return false;
}
 
Anonymous
Not applicable

Re: Collecting IP address once form is completed

Good approach but the JS example won't work in every browser, plus the ActiveX requirement will fail on restricted machines. But, it shows a common way of getting IP from external provider and using it in a form.
Anonymous
Not applicable

Re: Collecting IP address once form is completed

Georgi, I totally agree with your reamrks. I am originally Unix user, happy to ambrace Linux and Mac OS X.  

The example is agnostic

$(document).ready(function () {
  $.get('http://jsonip.com', function (res) {
  // assign the IP to a hidden field using res.ip
  });
});

Anonymous
Not applicable

Re: Collecting IP address once form is completed

Thanks Georgi, helped me out there too!
Anonymous
Not applicable

Re: Collecting IP address once form is completed

I need to save IP Address to a field in Salesforce for CASL compliance. How can we do this? I dont know Javascript or know where to put this and dont have developer resource or budget to hire Marketo. 
Anonymous
Not applicable

Re: Collecting IP address once form is completed

We have the same need for a legal requirement in Germany. Where would I put the JS code and how would that populate the hidden field?

Thanks!