This will convert a price based on the location of the respondent. This example will convert $100 USD to the equivalent in GBP and AUD. To set this up:
Create a URL variable in the variable manager that will be used to assign a region to respondents.
Add the following code to the JavaScript area, creating the convertCurrency function.
function convertCurrency(amountInUsDollars){
const poundsExchangeRate = .79;
const australianDollarExchangeRate = 1.54;
if(region === 'UK'){
return '£' + (amountInUsDollars * poundsExchangeRate);
}
else if(region === 'AU'){
return '$' + (amountInUsDollars * australianDollarExchangeRate)
}
else {
// US Dollar is the default
return '$' + amountInUsDollars;
}
}Use script to reference the new function in an area of your survey.