### [How to Set a Default Flag on Smart Phone Field with GDPR](https://wpforms.com/developers/how-to-set-a-default-flag-on-smart-phone-field-with-gdpr/)

**Published:** December 1, 2020
**Author:** David Ozokoye

**Excerpt:** This tutorial will show you how to set a default flag on your Smart Phone form field using JavaScript. 

**Content:**

Would you like to set a default flag on the **Smart Phone** field when GDPR is enabled? When using the **Smart Phone** form field, the default country flag will attempt to be set based on the user’s IP address. When the GDPR setting is enabled, this setting is blocked and therefore the flag would need to be set manually by your visitors.

Using a small JavaScript code snippet you can set the flag to a default country by a number so you’re not in violation of your GDPR agreement but saving the user a step at the same time. We’ll show you how to achieve this with this tutorial.

## Setting up the form

First, for the purpose of this tutorial, we’ll presume you have already enabled the WPForms GDPR setting. If you need further assistance with this, [please review this documentation](https://wpforms.com/docs/a-complete-guide-to-wpforms-settings/ "A Complete Guide to WPForms Settings").

Once the setting for GDPR is enabled, it’s time to add a **Smart Phone** to your form.

![Add a Smart Phone form field to your form](https://wpforms.com/wp-content/uploads/2020/12/wpforms-add-smart-phone-field.jpg)Now that the field is added, you can now add your **GDPR Agreement** form field as well.

![Next, add the GDPR Agreement form field to the form](https://wpforms.com/wp-content/uploads/2020/12/wpforms-add-gdpr-agreement.jpg)## Setting the default flag

Now it’s time to add the following code snippet to your site. If you not sure where and how to add snippets to your site, [please review this tutorial](https://wpforms.com/developers/how-to-add-custom-php-or-javascript-for-wpforms/ "How to Add Custom PHP or JavaScript for WPForms").

```

/**
 * Set the country code on Smart Phone form field country flag
 *
 * @link   https://wpforms.com/how-to-set-a-default-flag-on-smart-phone-field-with-gdpr/
 */
  
function wpf_dev_smart_phone_field_initial_country() {
    ?>

**Categories:** Fields

**Tags:** Javascript, JS, PHP

---

