Set Up User Context on Webflow

Pass logged-in user info from Webflow Memberships, Memberstack, or Outseta

Back to User Context
Standard & Pro Plans

What You're Setting

User Context is a client-side JavaScript object. On every page where the widget loads for a logged-in user, you attach an object to window.Asyntai.userContext describing who they are. The widget sends this with each message, so the AI can reply with their name, order status, plan tier, or anything else relevant.

Keys act as labels the AI sees, so make them descriptive — use "Customer name" or "Loyalty points", not just "name" or "points".

window.Asyntai = window.Asyntai || {};
window.Asyntai.userContext = {
  "Customer name": "Sarah Chen",
  "Email": "sarah@example.com",
  "Subscription plan": "Pro",
  "Loyalty points": 1840,
  "Last order": "#8847, out for delivery"
};

Two ways to set it

Either assign synchronously (if data is already on the page), or provide a fetcher that runs when the chat opens. The second option is better for performance — user data is only loaded when someone actually opens the chat.

// Option A — synchronous (data already available)
window.Asyntai.userContext = { "Customer name": "Sarah", ... };

// Option B — async fetch on chat open (better performance)
window.Asyntai.fetchUserContext = function() {
  return fetch('/api/chat-context/')
    .then(r => r.json())
    .then(data => { window.Asyntai.userContext = data; });
};

Security & size: Never include passwords, credit card numbers, API tokens, or anything sensitive — this data is on the client and visible to anyone inspecting the page. Context is capped at 2,000 characters on Standard and 10,000 characters on Pro; if you exceed it, the tail is truncated.

How Webflow Handles Users

This is the trickiest platform for user context. Webflow's native User Accounts feature does not expose the logged-in user to client-side JavaScript — the session token lives in an HTTP-only cookie that scripts cannot read, and Webflow has no public JS API like window.wf.user. You have three real options, ordered from easiest to most custom.

Option 1 — Webflow Native Users via User Account Page (workaround)

The standard workaround: add a User Account page (Pages → add User Account page) that Webflow pre-fills with the logged-in user's data. Place a hidden form there containing the fields you want to expose, then read those fields from the DOM with a script.

1
Create (or open) your User Account page Webflow Designer → Pages panel → Utility Pages section → User Account page. This page is the only place Webflow auto-fills with user field values.
2
Add a hidden div with user fields Drop a div on the page, give it an ID like asyntai-user-data, and inside it place text blocks whose content is bound to user fields (Name, Email, custom fields). Set the div's display to none.
3
Read those fields with a script on the same page Add an embed (or page-specific custom code) that reads the text values and assigns them to window.Asyntai.userContext.
<!-- On the User Account page only -->
<script>
(function() {
  var root = document.getElementById('asyntai-user-data');
  if (!root) return;
  var get = function(sel) {
    var el = root.querySelector(sel);
    return el ? el.textContent.trim() : '';
  };
  window.Asyntai = window.Asyntai || {};
  window.Asyntai.userContext = {
    "Name":  get('[data-field="name"]'),
    "Email": get('[data-field="email"]'),
    // Add any custom user fields you surfaced in the hidden div
  };
  // Persist to sessionStorage so other pages can reuse it
  sessionStorage.setItem('asyntai_user', JSON.stringify(window.Asyntai.userContext));
})();
</script>

On every other page, read from sessionStorage in the Footer Code:

<script>
var saved = sessionStorage.getItem('asyntai_user');
if (saved) {
  window.Asyntai = window.Asyntai || {};
  window.Asyntai.userContext = JSON.parse(saved);
}
</script>

Why this workaround exists: Webflow deliberately keeps the session token in an HTTP-only cookie, which means no JavaScript (yours or anyone else's) can read it. The User Account page is the only place Webflow renders user data into the DOM — so it's the only client-side source of truth. For sites that need rich user data everywhere, most people move to Option 2 or 3 instead.

Third-party shortcut: The free "SA5 Logged-In User Info" library from Sygnal does exactly this for you — it adds data attributes to Webflow elements and gives you a JS API to read the logged-in user. If you'd rather not build the hidden-field approach yourself, it's a drop-in alternative.

Option 2 — Memberstack

Memberstack is the most popular auth layer for Webflow. Memberstack 2.0 exposes window.$memberstackDom with a getMemberJSON() call:

<script>
window.Asyntai = window.Asyntai || {};
window.Asyntai.fetchUserContext = async function() {
  if (!window.$memberstackDom) return;
  const { data: member } = await window.$memberstackDom.getCurrentMember();
  if (!member) return;
  window.Asyntai.userContext = {
    "Email": member.auth.email,
    "Plan":  member.planConnections && member.planConnections[0]
      ? member.planConnections[0].planName
      : 'Free',
    "Custom fields": JSON.stringify(member.customFields || {})
  };
};
</script>

Option 3 — Outseta

Outseta (another popular Webflow auth) exposes an asynchronous getUser() helper once the Outseta script loads:

<script>
window.Asyntai = window.Asyntai || {};
window.Asyntai.fetchUserContext = function() {
  if (!window.Outseta) return Promise.resolve();
  return window.Outseta.getUser().then(user => {
    if (!user) return;
    window.Asyntai.userContext = {
      "Name":  user.FullName,
      "Email": user.Email,
      "Plan":  user.CurrentSubscription ? user.CurrentSubscription.Plan.Name : 'None'
    };
  });
};
</script>

Petua: All three snippets go under Project Settings → Custom Code → Footer Code (site-wide). Webflow injects them on every page, and fetchUserContext only runs when the chat actually opens — so the extra auth call is zero cost for visitors who never chat.

API stability: Webflow's native user-account endpoint and Memberstack/Outseta APIs occasionally change shape between major versions. If fields come back empty, open DevTools → Console and log the full response object to see the current structure.

Penyelesaian Masalah

The AI doesn't seem to know who I am

Open your browser DevTools → Console → type window.Asyntai.userContext after the page loads. You should see your object. If it says undefined, your script didn't run — check the script order (context must be set after the widget script loads, or be re-set whenever the user logs in).

Context works on some pages but not others

The widget reads window.Asyntai.userContext on every message. If a page loads fresh (no SPA routing), you need to set context on that page too. For single-page apps, set it once after login and update it whenever user data changes.

Data is stale after the user updates their profile

Re-assign window.Asyntai.userContext with the fresh data after any update. The next message the user sends will include the updated values — no page reload needed.

Context is truncated

You're over the size limit (2k chars Standard, 10k Pro). Trim verbose fields — keep order history to last 2-3 items, truncate long descriptions, drop fields the AI doesn't need.

User Context status page shows "Not receiving context"

Visit the User Context settings page while logged in as a test user, then send a chat message. The status refreshes within a few seconds. If still empty, check the browser console for JavaScript errors and verify the object is set before the chat message is sent.

Privacy reminder: Only share fields relevant to the conversation. Passing a customer's full purchase history when they just want to ask a general question is wasteful and can confuse the AI. Scope context to what helps.