Capture IP Address

I wondered if anyone knows if it is possible to capture an IP address of a user or someone completing a web page please.

Thanks in advance.

Sarah

Hi Sarah, we do this at Croydon, I can try to package it up for you, or we can jump on a call to go through it

here is the code, plus there is a reference to the object where the data is stored

//
var ip = cs.get_session_ip_address();
var context_record_id = params.record_id;
var context_record = cs.record(context_record_id);

if (ip && ip.length > 0) {
cs.save(
context_record.get_object_id(),
{
‘:id’: context_record_id,
‘application_ip_address_field’: ip,
}
);
} else {
cs.log(‘Could not get IP address’);
}

2 Likes

That’s great Kevin, Thank you.