I guess this isn't a webforms specific question, but it might have been solved here before.

I want to display an element based on the country that a user is from (based on GeoIP or Cloudflare / Akamai header), but I can't find anything particularly helpful on Google on how to do this. Ideally I could use a computed token or twig to pick up a specific header, but I'm struggling to find the right way to do it.

Many thanks!

  • You need to provide more information on the header you're identifying. What is it? What are the possible values etc? Link to documentation? – Jaypan Aug 11 at 10:23
  • Simplest solution probably to create variant forms and put them on different paths based on the country, then redirect depending on the country: the redirection approach is a technique you will find lots of documentation and tips for, and it avoids any need for complex caching strategies. – Alfred Armstrong Aug 12 at 10:24
  • I've just found support.cloudflare.com/hc/en-us/articles/… which explains what Cloudflare would set the header to be: Header name: HTTP_CF_IPCOUNTRY Values: GB, US etc Good point about caching - maybe I would need separate forms. That's okay because there should only be three variants. – Digby Aug 13 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.