All Collections
Integration Guides
ClickFunnels
ClickFunnels location extraction [advanced guide]
ClickFunnels location extraction [advanced guide]

Adding location variables to your ClickFunnels integration.

Fomo avatar
Written by Fomo
Updated over a week ago

ClickFunnels only provides "server IP" addresses to 3rd party integrations, so Fomo can't detect the location of your leads without annoying "city, state, country" fields in your form.

Since that's really annoying, we built a workaround.

Follow the guide below to take advantage of #{{ city }}, #{{ province }}, and #{{ country }} merge variables in your ClickFunnels integration, without adding any more inputs to your ClickFunnels forms.

Step 1 - Open your Funnel Form / Popup

Open the Page Editor for any page of your funnel that has a contact or purchase form.

In the example below, we're opening up a Popup Form.

Notice the ability to "add new element" below our bottom-most form field. We'll use this in the next step.

Step 2 - Add new Form Element

Add a new Element to your form.

On the right side, select the "Input" type underneath the "Form" category.

Step 3 - Configure and Hide the New Element

Immediately after selecting the 'Input' type in Step 2, you'll see a new field appended to your form.

Click that form field to modify it:

On the right side, several options will appear.

Simply change the Input Type to Zip and click the 'eyeball' icon along the bottom to "Hide" this field.

You should now see your form again, but without this field we just created.

Step 4 - Add Location Detection

Now that our form has a hidden field, we just need to add a snippet of code that will "fill in" this field with your visitors' IP Address, to then be sent to Fomo and turned into a set of location parameters.

Along the top navigation, hover Settings > Tracking Code > Footer.

After you're in the "footer" tab of this popup window, paste the following code:

<script>
  var ipAddress;

  function getIpAddress() {
    $.getJSON('//geocode.usefomo.com/json/', function(data) {
       ipAddress = data.ip;
       console.log('ip: ' + ipAddress);
      });
  }

  function injectHiddenField(ip) {
    var hiddenField = $('input[name="zip"]');
    hiddenField.val(ip);
  }

  function fetchAndInjectIpAddress() {
    getIpAddress();

    var ipSetter = setInterval(function() {
      if (ipAddress && ipAddress.length > 0) {
        injectHiddenField(ipAddress);
        clearInterval(ipSetter);
      }
      else {
        console.log('ip not found, retrying.');
      }
    }, 150)
  }

  fetchAndInjectIpAddress();
 </script>

This snippet does 2 things:

  1. Fetches your visitor's IP address after the page loads (won't slow down your site)

  2. Inputs that IP address into the hidden "zip" field we created on your form

Step 5 - Extract Location Data from the IP Address

Find your ClickFunnels template > Advanced > Extract location data from event IP address. Make sure this is enabled and click the orange "Save" button:

Step 6 - You're done!

Remember to click 'Save' in the top right, to reflect all these changes on your funnel page.

Repeat Steps 1-5 above for each funnel page that has a form for New Contacts or Purchases.

Going forward, all new contacts and purchases will have accurate City, Province, and Country parameters which you can embed inside your ClickFunnels templates.

Need more help? Let us know.

Did this answer your question?