Streaming live at 10am (PST)

How to track IP Address of people who fill out a form


#1

Does anyone know how to collect the IP address of those who fill out form?

I have tried following these instructions bt so far its not working.

Here is the site.
https://preview.webflow.com/preview/vopalpha?utm_source=vopalpha&preview=bdc631b8774a5f605757dd9fbf821048


#2

What you need to do is:

  1. Make a form on your page
  2. Style it however you like and give it the inputs you need
  3. Make one more input, and give it an ID of ipFormInput in the Webflow designer
  4. Set this last field to hidden so that users don’t see it
  5. Copy this code into your page’s footer code:
<script type="application/javascript ">
    const ipFormInput = document.getElementById('ipFormInput');

    fetch('https://api.ipify.org?format=json')
        .then((response) => { return response.json() })
        .then((json) => {
            let ip = json.ip;
            ipFormInput.value = ip;
        })
        .catch((err) => { console.log(`Error getting IP Address: ${err}`) })
</script>

This script makes a call to an external service that returns the client’s IP address. It then sets the IP address as the value of the form field that has the ID ipFormInput. As long as you make this field hidden from the Webflow designer, the user will never see it. When the form is submitted you will get the IP address along with the other form fields.

I just wrote this and tested it, it works fine.

Hope that helps.
Jason


#3

Hi Jason,

Thank you very much for your help. It hasn’t worked for me. Not sure what I am doing wrong.

https://preview.webflow.com/preview/vopalpha?utm_source=vopalpha&preview=bdc631b8774a5f605757dd9fbf821048

Regards
Dave


#4

Hi Jason,

I just got it working. Thanks heaps mate.

Much appreciated.


#5

Cool, glad it works for you!