Pass the page, article or product to the web chat

The web chat sends the page the visitor is on by itself, and your site can add the article, product, plan or other data so your team knows what the customer is talking about before asking.

Updated on November 3, 2026· 6 min read

When someone writes "do you have this in size M?", your team needs to know which product they were looking at. The web chat can send that context along with each message, and your team sees it in the inbox. This guide is for whoever builds the site. First: install the web chat.

The context is help information for the agent. It doesn't identify the customer or grant permissions: to know who they are, see Identify signed-in customers.

What is sent automatically (you do nothing)

Data What is sent
Page The page address, without the fragment (#…) and without query parameters, except utm_* (campaigns).
Title The page title (document.title), up to 200 characters.
Origin Where they came from (the browser's referrer), cleaned with the same rules.

While the tab is visible and a conversation already exists, the chat checks every 2 seconds whether the page or the context changed; if so, it tells Turnflow. That way the page history builds up even if the visitor browses without writing.

What you configure: window.TurnflowChat.context

Define this object on your page, before or after the chat code (the chat reads it live, whenever needed). All fields are optional:

<script>
  window.TurnflowChat = window.TurnflowChat || {};
  window.TurnflowChat.context = {
    page:   { url: "https://…", title: "…" },          // only if you want to replace the automatic one
    item:   { type: "producto", id: "SKU-123", name: "Soy candle 200 g", url: "https://…" },
    custom: { cart: "3 items", plan: "pro" }          // whatever your team needs
  };
</script>
Field What it is Limits
page.url, page.title Current page. Usually not needed: it is taken automatically. Useful in single-page applications. http(s) URL; title up to 200 characters
item.type Type of what they are viewing: articulo, producto, plan… (any short word). With articulo and producto the inbox shows it with a translated label ("Article" / "Product"). Lowercase letters, numbers, - and _; up to 40 characters
item.id Identifier (SKU, article id…). Up to 80 characters
item.name Display name. Up to 200 characters
item.url Link to the article or product. http(s) URL
custom Free "key: value" pairs. At most 10; key up to 40 characters (letters, numbers, space, ., -, _); value text, number or true/false, up to 200 characters

General limits (the server always applies them, even if the browser was tampered with):

  • The whole context can't exceed 2 KB. If it does, whatever no longer fits is dropped, with no error.
  • Addresses can only be http or https (javascript:, data:, file: and so on are dropped), and are trimmed like the page: no fragment, no user or password, only utm_*.
  • Anything not in the table is ignored.
  • Every time the visitor writes, the current context is sent and replaces the previous one. The page history is kept.

The value item.type uses the same words in every language (articulo, producto); the label the agent sees is translated.

Examples

A blog (article)

<script>
  window.TurnflowChat = window.TurnflowChat || {};
  window.TurnflowChat.context = {
    item: { type: "articulo", id: "42", name: "How to choose a scented candle", url: location.href },
    custom: { category: "Guides", author: "Editorial team" }
  };
</script>

In WordPress, inside a post template (single.php), with the article's data; wp_json_encode safely escapes the text:

<script>
  window.TurnflowChat = window.TurnflowChat || {};
  window.TurnflowChat.context = {
    item: <?php echo wp_json_encode([
      'type' => 'articulo',
      'id'   => (string) get_the_ID(),
      'name' => get_the_title(),
      'url'  => get_permalink(),
    ]); ?>
  };
</script>

A store (product and cart)

<script>
  window.TurnflowChat = window.TurnflowChat || {};
  window.TurnflowChat.context = {
    item: { type: "producto", id: "SKU-123", name: "Soy candle 200 g", url: "https://mystore.com/candles/soy-200" },
    custom: { price: "$38.00", availability: "4 left", cart: "2 items, $76.00" }
  };
</script>

In a store with a cart page, use item.type: "carrito" or a custom.carrito field. If the visitor moves to another product without a page reload, update the object (window.TurnflowChat.context = {…}) when the route changes.

A SaaS (plan and account)

// after loading the user's session in your application
window.TurnflowChat = window.TurnflowChat || {};
window.TurnflowChat.context = {
  item: { type: "plan", name: "Pro plan" },
  custom: { account: "Acme Inc.", status: "Trial, day 9 of 14", screen: "Billing" }
};

To know who the person is, use the signed identity; here you only pass supporting data. In single-page applications (React, Next.js), reassign window.TurnflowChat.context when the screen changes.

What your team sees

In the Inbox, open a Web chat conversation and click Customer (on wide screens the panel is already on the right). Under the name there is Visit context:

  • Current page: the title as a link to the page.
  • Viewing (or "Article" / "Product"): the name of the article or product, with a link if you sent one.
  • Came from: the origin.
  • Each custom item, with its key as the label.
  • Pages visited: the last 5 pages they went through during the conversation (shown when there was more than one).

Everything is shown as text: it is never interpreted as HTML and links only open if they are http or https. For now this context is for your team; the bot and the AI don't use it.

Privacy: what to send and what not to

The context is written by the visitor's browser and can be seen by anyone on your team with access to that conversation; it is stored with it. Therefore:

  • Don't send passwords, tokens, card numbers or other payment data, identity document numbers, or medical or sensitive information.
  • Turnflow already removes the fragment and every non-utm_* parameter from addresses, because they often carry emails, tokens or personal identifiers. Still, don't put personal data inside custom unless you really need it to give service.
  • Be careful with texts you build from user data: although Turnflow shows them as text, escape them when generating your HTML (in PHP wp_json_encode/json_encode, in JavaScript JSON.stringify).
  • A context is not proof: anyone can alter it from their browser. Don't use it to decide permissions or discounts; confirm anything important with your own system.

Common problems

  • I don't see the context in the inbox: it only appears in Web chat conversations and after the visitor sends the first message. Check that window.TurnflowChat.context is an object (not text) and doesn't exceed 2 KB.
  • A URL is missing: it is dropped if it isn't http(s); check it isn't relative-empty or using another protocol.
  • A custom key is missing: you may have gone over 10 keys, the key may be over 40 characters or contain disallowed characters, or the value isn't text, a number or true/false.
  • The page shows the address without my parameters: that's on purpose (only utm_* is kept). If you need a value from the URL, put it in custom.
Was this article helpful?