Free Plugin: Clickfunnels country auto-selector

:police_car_light: Legacy Script Notice: This thread originally provided a custom JavaScript snippet designed for ClickFunnels 1.0.

:rocket: Experience Funnelish v2: Tired of patching together custom code snippets for essential checkout features? We’ve evolved! Funnelish v2 is now a complete e-commerce funnel platform that combines the high-converting sales funnels of ClickFunnels with the powerful backend functionality of Shopify—all in one place.

With Funnelish v2, features like default country selection, advanced shipping rules, and localized checkouts are built right into our native forms. No coding required!

Relevant Links & Resources:


:laptop: ClickFunnels 2.0 Update: If you are using ClickFunnels 2.0, the original script below may not work as CF 2.0 doesn’t always load jQuery by default and uses different form structures. Use this updated Vanilla JavaScript version in your Tracking Code (Footer) instead:

<script>
  const FNSH_COUNTRY_CODE = "US"; // Set your default country code here
  const FNSH_HIDE_COUNTRY_BOX = false;
  const FNSH_DISABLE_COUNTRY_BOX = false;

  document.addEventListener("DOMContentLoaded", function() {
      const countryBoxes = document.querySelectorAll("select[name*='country'], input[name*='country']");
      
      countryBoxes.forEach(function(box) {
          box.value = FNSH_COUNTRY_CODE;
          
          if (FNSH_HIDE_COUNTRY_BOX) {
              box.style.display = 'none';
          } else if (FNSH_DISABLE_COUNTRY_BOX) {
              box.disabled = true;
          }
      });
  });
</script>

:backhand_index_pointing_down: Did this script work for you? Have any questions about how Funnelish handles localization natively? Drop your feedback in the replies below!

General scripts clickfunnels Feature requests


What is “Clickfunnels country auto-selector”?

This script plugin auto-selects a country of your choice and optionally hides it from your end-users. By setting a default value to your Clickfunnels country select box in your order form.

This might help in cases where Clickfunnels fails to track the country field of your customers.

How to add it to your Clickfunnels funnel?

  1. Open your Order Form funnel step

  2. Click on Edit page button.

  3. Go to SETTINGS > TRACKING CODE.

  4. Add this script to your FOOTER CODE as it is.

<script>
  var FNSH_COUNTRY_CODE = "US";
  var FNSH_HIDE_COUNTRY_BOX = false;
  var FNSH_DISABLE_COUNTRY_BOX = false;

   $(document).ready(function() {
       let country_box = $("[name='shipping_country'], [name='country']");

       country_box.val(FNSH_COUNTRY_CODE);
       if (FNSH_HIDE_COUNTRY_BOX) {
           $(country_box).hide();
       } else if (FNSH_DISABLE_COUNTRY_BOX) {
           $(country_box).attr('disabled', true);
       }
   });
 </script>
  1. Add an input box* for country to your Order Form, If you haven’t already
    Clickfunnels country order form box

Don’t forget to set the Input Type to Shipping Country or Country depending on your use case.

  1. Replace “US” (in the second line) with your desired default country ISO code, (e.g. “UK”, “AU”, “GR”…etc).

  2. Set FNSH_HIDE_COUNTRY_BOX to true to hide the country box
    In case you want to prevent your customers from changing the country value, you may replace the true value above to false. that way the country field will be hidden from your customers but the value will be set to the value given.

  3. Set FNSH_DISABLE_COUNTRY_BOX to true to disable the country box
    When changed to true, the country box will be disabled but will still be visible.

  4. Hit save and that’s it.

2 Likes

A really nice plugin does the job correctly and doesn’t affect my order form load time. In fact, it increased the conversion rate a bit and decreased the error rate on our order form as well. Most people used to write inconsistent answers on the order form (e.g. “US”, “USA”, “united states”, “America”…etc)

1 Like

Simple solution, thanks so much - exactly what I needed for a physical (big!) product funnel. Cheers!

Actually - doesn’t seem to work with the updated address module in CF :frowning:
I’m guessing it’s an easy fix but my hacking didn’t get it to work :slight_smile:

Hello,

This code removes the entire address selection on my funnels. Any idea what to do in order to keep the address but not the country (or have the country set to a specific country)?

1 Like

Can you share a sample link to a landing page or order form where you have that code to see what you mean perhaps that can help us fix the issue!

Hello Samlee, Is there a way to select a country by default and do not allow customers to change it? whithout making the whole country selection dissapear? I want the to be visible but do not allow changing it.

thanks a lot!

1 Like

Hello, Is there a way to select a country by default,but do not allow customers to change it? Without making the whole country selection dissapear?

I want the to be visible, but not allowing my customers to change it.

1 Like

Hello @eliotcorral,

I changed the code above and edited the article to add the ability to disable the country selector, by changing the “FNSH_DISABLE_COUNTRY_BOX” variable.

Copy the new code from the first post, scroll up or click here: https://community2.funnelish.com/t/free-plugin-clickfunnels-country-auto-selector/81?u=samlee.

thanks! I also got this code and it worked (just change MX with the desired country code)

This little code snippet worked great for me.

The setting to hide the country box though is a problem as then the button pops up and is covered by the zipcode box. Not sure why it does that so I just left it visible but set it to prepop to United States.
You can see my working sample at this site:
(although I’m guessing this link might be removed as not allowed… not trying to advertise but just show a sample of this code snippet in working order)

I need a code like this for Click Funnels 2.0 but cant seem to get it to work. I also need to preselect and prevent selection of the State field too - would anyone be able to help with this?

1 Like