Using window.sessionData between pages

Forward a submitted email (or name, phone, etc.) from a previous opt-in step into a link URL on a downstream funnel page — for example, to hand it off to an external integration.

A common integration need: a visitor opts in on one funnel step, and on the follow-up page you want a link (to an external service, a webhook, a registration URL, etc.) that already contains the email they just submitted — e.g. https://clickfunnels.com/[email protected].

This guide shows the supported way to do that, the one mistake that makes it silently fail, and a copy‑paste code sample. It was verified end‑to‑end against a live funnel.

📘

TL;DR

Merge tags like {contact.email} are not substituted in page content — they render literally. Instead, read the submitted value at runtime from window.sessionData.contact in a small footer script and write it into your link. Match links by their destination domain, not by a placeholder token.

Why {contact.email} in a link doesn't work

If you type https://clickfunnels.com/register?e={contact.email} into a link, the page renders that text verbatim — the visitor's browser receives the literal string {contact.email}. Page content is not run through a merge‑tag/Liquid pass, so there is nothing to substitute the token.

The supported approach: window.sessionData + a footer script

Every rendered funnel/landing page exposes a JavaScript object describing the current contact:

window.sessionData = {
  contact: { email: "[email protected]", first_name: "Jane", /* … */ },
  checkout_v2_state: "guest"
};

window.sessionData.contact is populated once the visitor has opted in, and it is carried to later steps in the same funnel automatically (via the contact's session). So on the Thank You page you can read window.sessionData.contact.email and rewrite your links with it.

Recommended code sample

Add this to the Thank You page's footer / tracking code (in the editor: Settings → Tracking Code → Footer). Replace example.com with your integration's domain and email with whatever query parameter that service expects (e.g. e).

<script>
  (function () {
    var contact = window.sessionData && window.sessionData.contact;
    var email = contact && (contact.email || contact.email_address);
    if (!email) return; // visitor hasn't opted in yet — leave links untouched

    // Match links that point at your integration's domain, then append the email.
    document.querySelectorAll('a[href*="example.com"]').forEach(function (a) {
      var url = new URL(a.href, window.location.origin);
      url.searchParams.set('email', email);   // → ?email=jane%40acme.com (auto‑encoded)
      a.href = url.toString();
    });
  })();
</script>

A link on the page like:

<a href="https://clickfunnels.com/register">Continue →</a>

becomes, at view time:

https://clickfunnels.com/register?email=jane%40acme.com

⚠️ Pitfalls

A natural first attempt is to put the placeholder in the link and string‑replace it:

// ❌ Don't do this — it usually matches nothing.
document.querySelectorAll('a[href*="{contact.email}"]').forEach(/* … */);

This fails because the editor URL‑encodes the link, so { and } become %7B and %7D in the actual DOM. The selector a[href*="{contact.email}"] then matches zero elements and nothing happens. Always match on the destination domain (as in the recommended sample) and build the final URL with the URL / searchParams API rather than replacing a literal token.

Three things to check if the link still isn't being rewritten:

  1. The visitor hasn't opted in. window.sessionData.contact is only populated after an opt‑in submission. Test by actually submitting the opt‑in step, not by loading the Thank You page cold.
  2. The steps are on different domains. The contact session is per‑funnel/domain. Keep the opt‑in and Thank You steps in the same funnel on the same domain.
  3. Wrong field name. Read contact.email (fall back to contact.email_address).


Appendix — build this funnel with the API

The screenshots above come from a two‑step funnel created entirely through the public API: an Opt‑In page (email capture) and a Thank You page (the pre‑filled link + the footer script). Page visual content is authored in PML via the markup field.

🚧

Creating funnels/pages via the API is currently in limited beta. The footer script can always

be added in the page editor regardless.

1. Create the funnel

curl -sS -X POST "https://api.myclickfunnels.com/api/v2/workspaces/<WORKSPACE_ID>/funnels" \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"funnel":{"name":"Email in Link Demo","current_path":"/email-in-link-demo"}}'
# → 201; capture the funnel's "public_id"

2. Create the Opt‑In page (step 0) — an email input + submit button:

{
  "page": {
    "name": "Opt-In",
    "current_path": "/optin",
    "sort_order": 0,
    "funnel": { "funnel_id": "<FUNNEL_PUBLIC_ID>" },
    "markup": "<section bg=\"linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%)\" padding=\"120 40\"><row><column><headline fontsize=\"76px\" weight=\"black\" align=\"center\" color=\"#ffffff\" font=\"Poppins\">Watch Your Email <span color=\"#818cf8\">Follow You</span></headline><paragraph size=\"m\" color=\"#cbd5e1\" align=\"center\" font=\"Inter\">Enter an email and submit. On the next page a link is automatically pre-filled with it.</paragraph><input label=\"Email Address\" type=\"email\" placeholder=\"[email protected]\" required=\"true\" width=\"100%\" radius=\"md\"/><button bg=\"linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%)\" color=\"#ffffff\" fontsize=\"18px\" radius=\"full\" align=\"center\" font=\"Poppins\">Show Me →</button></column></row></section>"
  }
}

POST https://api.myclickfunnels.com/api/v2/workspaces/<WORKSPACE_ID>/pages with that body.

3. Create the Thank You page (step 1) — note the clickable link uses <link href> (buttons in PML do not take an href):

{
  "page": {
    "name": "Thank You",
    "current_path": "/thank-you",
    "sort_order": 1,
    "funnel": { "funnel_id": "<FUNNEL_PUBLIC_ID>" },
    "markup": "<section bg=\"#0f172a\" padding=\"110 40 56 40\"><row><column><headline fontsize=\"72px\" weight=\"black\" align=\"center\" color=\"#ffffff\" font=\"Poppins\">Your Email Is Now <span color=\"#34d399\">in the Link</span></headline><paragraph size=\"m\" color=\"#cbd5e1\" align=\"center\" font=\"Inter\">A small script read the email you submitted and appended it as ?email=…</paragraph></column></row></section><section bg=\"#ffffff\" padding=\"56 40\"><row><column><link href=\"https://clickfunnels.com\"><span color=\"#4f46e5\" fontsize=\"22px\" weight=\"bold\" font=\"Poppins\">Open the pre-filled link →</span></link></column></row></section>"
  }
}

4. Add the footer script — after the markup

curl -sS -X PATCH "https://api.myclickfunnels.com/api/v2/pages/<THANK_YOU_PAGE_ID>" \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"page":{"footer_code":"<script> … the snippet above … </script>"}}'
⚠️

Order matters. Sending markup rebuilds the page's rendered data, which clears any existing footer_code. Always set footer_code last — after the final markup update — or

re‑apply it whenever you change the markup.

Verify: open the published Opt‑In page, submit a test email, then open the Thank You page and confirm the link reads https://clickfunnels.com/?email=<your‑email>.