Skip to main content
When a page exists in more than one language, ElasticFunnels can suggest the visitor’s language (“This page is also in Română”) and fill in a language switcher. It never redirects anyone on its own: the visitor decides, and the choice is remembered. You can use EF’s small built-in prompt, or write your own markup and styles and let ElasticFunnels handle when to show it, what it links to and what the visitor chose. The API is shaped like the cookie consent one on Privacy & consent, so if you built a consent banner, this works the same way.
The prompt is off by default. Until you turn it on, nothing shows. It only applies to pages that exist in another language: linked translations, or a dictionary page under prefix routing. Other pages stay exactly as they are.

Turning it on

1

Have a page in two languages

Set up your languages and at least one translated page. See Multilingual sites.
2

Pick the prompt

In Pages → Advanced → Translations, under Language URLs, set Language suggestion, or use the CLI:The Language URLs settings under Translations: the Serve pages under language folders switch, Language suggestion set to Built-in prompt, and Fallback language for search engines
3

Check it

Open a translated page in a browser set to the other language, in a private window (a stored choice hides the prompt).

When the prompt shows

ElasticFunnels picks at most one language to suggest:
  1. The visitor’s browser languages (navigator.languages), in their order.
  2. If none of those match, the language of the visitor’s country.
Only languages the page exists in are suggested, never the one the visitor is already reading. Then:
  • It never redirects. The visitor moves only by clicking.
  • No prompt for bots. Search engine crawlers and automated browsers (navigator.webdriver) get no suggestion, so every version is crawled as it is.
  • Once per visitor. Accepting or dismissing stores the choice in the ef_lang_choice cookie (ro, or dismissed:ro; 180 days, whole site) and in local storage. A dismissed suggestion does not come back.
  • An accepted language follows the visitor. After choosing Romanian, a page that has a Romanian version suggests it, even when the browser says otherwise.

The built-in prompt

With Built-in prompt, a small card at the bottom of the page names the language and offers two buttons: go to that version, or stay. It is a plain white card in the visitor’s system font. The built-in language prompt at the bottom of an English page for a visitor whose browser is in Romanian: Această pagină există și în Română, with Rămân aici and Treci la Română buttons The card is written in the language it offers. Built-in texts exist for Romanian, Spanish, Portuguese (also Brazilian), French, German, Italian, Dutch, Polish, Turkish and Swedish; any other language gets English (“This page is also available in …”). To use your own words, add these keys to the brand dictionary in the suggested language (see Add texts). Your keys win over the built-in texts:

Your own prompt

With My own markup (or Built-in prompt, when the page has its own), your markup and styles are the prompt. ElasticFunnels shows it, fills it in and handles the clicks. Put the element on the page, or in a component every page includes, with the hidden attribute so it stays out of sight until there is something to suggest. A complete example, a card in the corner with its own styles and a short script that writes the sentence in the suggested language:
A footer link that brings it back:
The lp- class names, the colours and the texts are all yours. Only the data-ef-lang-* attributes matter to ElasticFunnels. With dictionary pages, write the texts as t() keys instead of the script’s list.

A language switcher

Add an element with data-ef-lang-switcher. Leave it empty and ElasticFunnels fills it with one link per language the page exists in, the current one marked with aria-current:
To control the markup, put your own links inside, one per language, with data-ef-lang-option="<code>". ElasticFunnels sets their href, hreflang, lang and aria-current, and leaves everything else alone:
A click on a switcher link counts as the visitor’s choice, the same as accepting the prompt. You can also write the switcher in the template from the translations variable; see Template variables.

For developers: the window.ef.i18n API

On pages that exist in another language, window.ef.i18n is available from the page’s <head> onwards. On other pages it is not defined, so check for it: window.ef && window.ef.i18n. current is the page’s language code. languages lists every version: { code, hreflang, name, url, current }. choice is the stored choice ('ro' or 'dismissed:ro'), or null.

Events

The page fires these events on window: Each carries the same detail:
source is prompt for a click in the prompt, api for a call to window.ef.i18n, switcher for a switcher link, and stored for a suggestion that comes from a language the visitor accepted earlier.

Google Tag Manager

Every choice is also pushed to dataLayer:
action is accepted or dismissed. In Google Tag Manager, a Custom Event trigger on ef_language_choice and a Data Layer Variable ef_language.lang tell you which languages visitors pick.