I recently developed a plugin (available on CodeCanyon) that will store the current location (country and continent) of the user submitting a form designed in Gravity Forms. This plugin regularly downloads the latest Geo information from MaxMind Geolite2 and uses that to determine where the user is coming from.

This post details how to set Gravity Forms Geo Conditional Fields up so that you set different feeds to process based on the users geographical location. For example, you may need all users in Australia to be sent to your Australian PayPal account and all users in United States  to be sent to your United States PayPal account, or perhaps you need all users in Australia to subscribe to mailing list A and all other users to be subscribed to mailing list B.

Setting Your Field Up

In order to setup and process feeds based on a users geographical location, you will need to use either a custom merge tag that has been included with this plugin or the actual Geo Country or Geo Continent fields.

For those that don’t know what a merge tag is, it’s a special code that you can setup in Gravity Forms which will be translated to a special value based on what the merge tag is. In our case the merge tags {geo_country} and {geo_continent} are used. Don’t be too concerned if you don’t understand the last sentence, as it will still work nonetheless. 🙂

Which method you use will depend on whether your feed plugin in the older style or the newer style. At the time of writing this, most of the feeds (like PayPal and MailChimp) are still using the older style feed design. For the older style feed design, you can use the {geo_country} and {geo_continent} merge tags. For the newer feed designs, you are able to use the actual fields directly.

Older Style Feed Design Setup

The first thing you will need to do is go into the form editor for your form and add a Hidden Field to your form. This is the field you will use for your feed ‘opt-in’ condition. After you add your field, click ‘Advanced’ and you will see a ‘Default Value’ input box.

hiddenfield

You can either type {geo_country} or {geo_continent} or select it from the drop down list.

Now whenever the form is displayed on the front-end of the website, you field will be loaded with the geo value you have selected. At this point you can now create a feed.

In your WordPress install when you click on the ‘Forms’ menu item, you will see a list of different items in the sub-menu underneath. Select the type of feed you would like to setup. In this case, for example, PayPal, or eWay etc..

formsmenu

 After you click ‘Add New’ you are taken to a page where you would normally enter your feed details. At the bottom of this page, you should see text that reads ‘Opt-In Condition’ or ‘Conditional’ or something similar with a checkbox to enable it.

condition

After you enable it, select the Geo Country field (or whatever you name the field label in the previous step) and then select ‘is’ or ‘is not’ and then your 2 character country code. 

That’s it! It should work now. Please note though, that not all feeds will support the required functionality to achieve this. Each feed needs to implement conditional logic for this to work.

Newer Style Feed Design Setup

The newer style of feeds does not require you to use a merge tag in order to get the field working. The newer style feeds support the native implementation of Gravity Forms conditional logic so the Geo Country or Geo Continent field can be used natively.

After you have added either a Geo Country or Geo Continent field on your form and saved it you can now add a feed. Newer style native feeds will appear in the ‘Form Settings’ drop down (Gravity Forms 1.7+).

nativefeeds

After you select the feed you want to create and click the ‘Add New’ button, you will notice the interface for conditional logic is similar to other areas in Gravity Forms.

newerfeedconditional

The newer style of feed processing in Gravity Forms is clearly king and hopefully more plugin developers will upgrade their feeds functionality soon to be able to take full advantage of native Geo Field support! Until then, though, Merge Tags is the way to go 🙂