Forms - Visibility Macro

Sathish Kannan asked on August 4, 2016 18:35

Hi,

How to write a macro in "Visibility Condition" (under "Forms -> Field advances settings") to field to display only if current visitor country is USA. I tried using this macro "Current visitor's country is one of the following countries: USA" but not working.

Here is my scenario,

I have two contact number fields in my form, one is US contact number which should display only if the current visitor from USA otherwise it should hide.

Another is International contact number which should display only if the current visitor is not from USA.

Please advice how to implement this.

Thanks in advance.

Recent Answers


Anton Grekhovodov answered on August 4, 2016 19:28

Hi Sathish,

Did you enable contact geolocation in Settings?

2 votesVote for this answer Mark as a Correct answer

Rui Wang answered on August 4, 2016 19:59 (last edited on December 10, 2019 02:30)

Hi Sathish

Once you make sure the contact geolocation is enabled, the next thing you can do is add this macro to a Editable region to see if you get any value.

{% AnalyticsContext.CurrentGeoLocation.Country.CountryName |(identity)GlobalAdministrator%}

In my case, when I did that on my localhost, it's not giving me any value because it's local IP. But when I tested this in a hosted site, it gives me "USA".

0 votesVote for this answer Mark as a Correct answer

Sathish Kannan answered on August 4, 2016 20:37 (last edited on August 4, 2016 20:38)

Thanks for your answers.

I tried all possible ways as you suggested but still not working.

Any other way to reach this. Can you please suggest

Thanks

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on August 4, 2016 20:58

Have you verified that your contacts have a country stored and that geolocation is working? Try to compare the country id(instead of the name) to 271 and see what it gives you. I believe 271 is usa as stored in the Kentico database. Curious to see if it could be a casting problem.

0 votesVote for this answer Mark as a Correct answer

Sathish Kannan answered on August 5, 2016 14:34 (last edited on August 5, 2016 17:17)

Hi All,

I tried using country id but still it is not working. It always showing USA, even if I try from outside USA.

Please suggest how to resolve this.

Thanks

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.