Contents
Country and language rules - Plugixa Chat
PRO Two rules target visitors by where they are and what language they read. Both are added on the builder’s When & where step, like any other rule.
| Rule | Looks at | Needs |
|---|---|---|
| Country | The visitor’s country | Something on your hosting that reports it. See below |
| Language | The languages set in the visitor’s browser | Nothing |
Typical uses: a WhatsApp number per country, a widget in each language of a multilingual site, or hiding a widget where you do not trade.
Country
- On the When & where step, add a rule and choose Country.
- Choose Show on or Except on.
- Pick one or more countries under Countries.
Where the country comes from
The plugin does not look up IP addresses itself and contacts no location service. It reads the country that your hosting already attaches to each request.
| Provider | Request header read |
|---|---|
| Cloudflare | CF-IPCountry |
| Vercel | X-Vercel-IP-Country |
| Amazon CloudFront | CloudFront-Viewer-Country |
| Google App Engine | X-AppEngine-Country |
| A server GeoIP module | GEOIP_COUNTRY_CODE |
A developer can also supply the country from code, through the
plugixa_chat_visitor_country filter. See
Hooks reference.
The status line
Above the country picker, the editor tells you whether country rules can work on this site, using your own request as the test.
| Message | Meaning |
|---|---|
| “Visitor countries are provided by … on this site.” followed by “You are seen as being in …” | A provider is reporting countries. The rule will work |
| “Visitor countries are provided by code on this site, through the plugixa_chat_visitor_country filter.” | A developer’s code is supplying the country |
| “This site cannot tell which country a visitor is in, so a country rule would hide the widget from everyone.” | Nothing is reporting a country. Do not rely on a Country rule yet |
The last message comes with the way out: “Put the site behind Cloudflare, Vercel or CloudFront, enable your server’s GeoIP module, or answer the plugixa_chat_visitor_country filter from your own code. Language rules need none of this - the browser reports the language itself.”
When the country is unknown
If a visitor’s country cannot be determined, a Country rule is treated as not matching. A Show on rule therefore hides the widget from that visitor. This is deliberate. Sites usually target by country because a licence or a regulation says they must, and showing the widget to the wrong country is the costlier mistake.
An Except on rule that cannot be checked does not hide the widget. If you must keep a widget out of certain countries, write the rule as Show on with the countries you do serve.
This holds whichever option is chosen under If a visitor check fails. See Settings.
Visitors that a provider cannot place, for example those arriving through Tor on Cloudflare, count as unknown.
Language
- On the When & where step, add a rule and choose Language.
- Choose Show on or Except on.
- Pick one or more languages under Languages.
The list offers common languages by name. To use one that is not listed,
type its code, for example ca or pt-BR, and press Enter.
“Matched against the languages set in the visitor’s browser. A rule for English also matches British and American English.”
- The rule compares the start of each language code, so
enmatchesen-GBanden-US, whilept-BRmatches only Brazilian Portuguese. - A visitor’s browser can list several languages. The rule matches if any of them matches.
- The rule looks at the browser, not at the language of the page. On a
multilingual site, to follow the page instead, use a Page address
rule such as “starts with
/fr/”.
If the browser reports no language at all, the rule is treated as not matching, as with an unknown country. On a site with a Show on widget per language, showing every one of them would stack them on top of each other.
Rules and page caches
Both rules are decided in the visitor’s browser, after the page has loaded, so they are right on a page served from a cache. Until the answer arrives the launcher’s place is kept but nothing is drawn.
A Country rule asks your site one short question per visit. That request
must reach WordPress, or at least pass through the provider that adds the
country, for each visitor. If your CDN is set to cache REST API responses,
exclude the address /wp-json/plugixa-chat/v1/context.
Combining with other rules
Country and Language belong to the visitor group of rules. Two Show on rules in that group are alternatives: “Show on: Country is France” with “Show on: Language is French” shows the widget to visitors in France and to French readers anywhere. To require both, set one of them the other way round, for example “Show on: Country is France” with “Except on: Language is English”. See how rules combine.
If Pro is removed
A stored Country or Language rule stays with its widget and keeps being applied on the site, because the check itself is part of the free plugin. The free builder lists the rule with its raw values and lets you delete it, but has no country or language picker. See Free vs Pro.
What to do next
- Add opening hours with Business hours.
- Review the other rules in Builder: When and where.