Capture country and language automatically | Community
Skip to main content
Answered

Capture country and language automatically

  • February 26, 2024
  • 2 replies
  • 106 views

Is there any way to capture country & language automatically from surveys? I’m trying to explain:

 

Having only 1 typeform, the user will open the URL and depending of the countries, it will capture locale. ie:

en_US (english, USA)

es_ES (spanish, Spain)

fr_FR (french_france)

 

I want to integrate typeform with Brevo but I want to avoid the ask language and country to the consumer due to ISO mapping issues.

 

Thanks for help! 

Best answer by mathio-tf

Hello @leuqim 

if you embed your typeform in your own website, you can pass the data to the form via hidden fields.

You can use navigator.language provided by the browser like this:

<div id="wrapper" style="width:100%;height:600px;"></div>
<script src="//embed.typeform.com/next/embed.js"></script>
<link rel="stylesheet" href="//embed.typeform.com/next/css/widget.css" />
<script>
window.tf.createWidget('<form-id>', {
  container: document.querySelector('#wrapper'),
  hidden: {
    language: navigator.language || 'unknown'
  }
})
</script>

 

Alternatively, if you do not want to rely on users browser language (it might be different from their actual language / location), you can retrieve the data from a 3rd party service (eg. https://ip-api.com/ or https://www.ipify.org/ or https://db-ip.com/) and pass those values as hidden fields. You can find a similar implementation with fetching the data from 3rd party API in this thread: 

 

View original

2 replies

Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 14858 replies
  • February 26, 2024

Hi @leuqim Oh yes, totally understand wanting to capture this information automatically! While we don’t offer this feature, do you happen to be embedding the form onto your website? If so, you might be able to capture this information through some coding. 

@mathio can offer insight on this!


mathio-tf
Typeform
Forum|alt.badge.img+5
  • Typeform
  • 888 replies
  • Answer
  • February 27, 2024

Hello @leuqim 

if you embed your typeform in your own website, you can pass the data to the form via hidden fields.

You can use navigator.language provided by the browser like this:

<div id="wrapper" style="width:100%;height:600px;"></div>
<script src="//embed.typeform.com/next/embed.js"></script>
<link rel="stylesheet" href="//embed.typeform.com/next/css/widget.css" />
<script>
window.tf.createWidget('<form-id>', {
  container: document.querySelector('#wrapper'),
  hidden: {
    language: navigator.language || 'unknown'
  }
})
</script>

 

Alternatively, if you do not want to rely on users browser language (it might be different from their actual language / location), you can retrieve the data from a 3rd party service (eg. https://ip-api.com/ or https://www.ipify.org/ or https://db-ip.com/) and pass those values as hidden fields. You can find a similar implementation with fetching the data from 3rd party API in this thread: 

 


Reply