Skip to content

Instantly share code, notes, and snippets.

@chrisgalard
Last active January 27, 2024 22:03
Show Gist options
  • Save chrisgalard/9987dba6c2c0374fed7ba5227e83b322 to your computer and use it in GitHub Desktop.
Save chrisgalard/9987dba6c2c0374fed7ba5227e83b322 to your computer and use it in GitHub Desktop.
These snippets of code will help you to add an international country code dropdown to your phone fields. Just add a normal Clickfunnels phone field and the code will do the rest!
<!--
International country code selector for Clickfunnels
Author: Chris Galard
Website: instagram.com/chrisgalard
License: You can do whatever you want with this code. We hope it helps you!
Want help with funnels & systems to grow your online course sales?
Book a call with me:
https://growthkingdom.com/results
Or DM me on IG: @chrisgalard
-->
<!-- START: Paste this in your header tracking code -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/build/css/intlTelInput.min.css">
<style>
[data-title='phone-container'] {
overflow: visible;
}
/* Get the phone input to expand to parent element width */
.intl-tel-input {
display: block;
}
/* Avoids Clickfunnels from hiding the flag names */
.intl-tel-input span {
display: initial !important;
}
</style>
<!-- END: Paste this in your header tracking code -->
<!-- START: Paste this in your footer tracking code -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/js/intlTelInput.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
var submitBtn = $('[href="#submit-form"]');
var phoneInput = $('input[name="phone"]');
// Enabling the phone number selector
iti = window.intlTelInput(phoneInput[0], {
nationalMode: false
});
});
</script>
<!-- END: Paste this in your footer tracking code -->
@sachinbothra
Copy link

Country code doesn't save at profile!

@oodledesign
Copy link

This looks perfect! But also doesn't save the country code for me which is what I need... Would be amazing if it could format the number on submission.

@Armay08
Copy link

Armay08 commented Dec 9, 2021

Can you help me edit this so I can show only the countries that I need?

@damianSebastian
Copy link

I would appreciate if you make the cde save the country prefix. Thank you!

@notricks9
Copy link

Is there a way to get this to work on a popup?

@chrisgalard
Copy link
Author

chrisgalard commented Jan 17, 2023

Hey everyone! The code has been updated.

First of all it was simplified so it's less prone to error.

Second, now it saves the country code in the contact profile inside of Clickfunnels.

Third, removed the validation so it doesn't keep your leads from opting in with their email if the phone is incorrect. The code was not allowing people to optin if their phone was incorrect or empty, and this was no bueno.

Let us know if you have any questions!

@walkeroundtown
Copy link

walkeroundtown commented Feb 20, 2023

Hey @chrisknowscode, how can i add the phone # validation back in? I'm getting a lot of fake phone numbers on CF

@WilliamDvsPro
Copy link

Hi, It work well! But I have a problem : I'm trying to put a country like FR or BE in the first results instead of US and UK, do you know how to do it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment