How to capture a member's IP Address

Article author
Josh Lopez
  • Updated

*Workaround for Webflow users

  1. Create a custom field called IP and hide it in Memberstack

  2. Create a text field in Webflow and insert the custom attribute: data-ms-member = ip

  3. Insert the Javascript (JQUERY):

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script>
    functiongetIp(callback) {
    functionresponse(s) {
    callback(window.userip);
    s.onload = s.onerror = null;
    document.body.removeChild(s);
    } function trigger() {
    window.userip = false;
    vars = document.createElement("script");
    s.async = true;
    s.onload = function () {
    response(s);
    };
    s.onerror = function () {
    response(s);
    };
    s.src = "https://l2.io/ip.js?var=userip";
    document.body.appendChild(s);
    }
    if (/^(interactive|complete)$/i.test(document.readyState)) {
    trigger();
    } else {
    document.getElementById("First-name").addEventListener("focusout", trigger);
    }
    }
    getIp(function (ip) {
    document.getElementById('IP').value = ip; console.log(ip);
    });
    </script>

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.