Skip to main content
Per-screen custom code lets you add JavaScript to individual screens using a Raw HTML element and the Fox API. Use it to read user answers, store computed values, and control navigation.
Custom code is not reviewed or controlled by FunnelFox. Make sure anything you add is reliable and thoroughly tested before using it in production.

How it works

Your custom JavaScript lives inside a Raw HTML element on a screen. To add code that applies to every screen at once, use funnel-wide custom code instead. The code runs immediately when the screen loads, and again every time the user navigates back to that screen. The Fox API (fox) is available globally from the moment the screen opens, no setup needed. Inputs are a persistent key/value store shared across all screens. When a user picks an option or fills a field, FunnelFox saves that answer to fox.inputs under the element’s ID. You can read those values, compute new ones, and write them back. They’ll be available on every screen.
Input values are always strings. Use parseInt(), parseFloat(), or Number() to convert them before doing math.
Only values you store with fox.inputs.set() persist across screens. Regular JavaScript variables (const, let) are reset every time the screen reloads.

Quickstart

1

Add a Raw HTML element

Add a Raw HTML element to the screen where you want your code to run.
2

Use Fox API

Inside the HTML content editor, add a <script> tag and use the Fox API. See the Fox API reference below for all available methods.
Use the Copy for LLM button at the top of this page to copy the Fox API reference in plain markdown, then paste it into any LLM (ChatGPT, Claude, etc.) and ask it to write the code for you.
Here’s a simple example that sends a custom analytics event and fires a Facebook pixel on quiz completion:

Use cases

Capture email from URL

When a user lands from an email campaign or app notification, read their email from the URL and bind it to their FunnelFox profile. This sets it as a user property forwarded to connected integrations like Stripe and Amplitude, so purchases are attributed correctly.

Calculate values from user input

Read user answers, run calculations, and store the result as a new variable. You can then use that variable anywhere in your funnel with {{variable-name}}, or use it to route users to different screens.

Custom backend integration

Intercept a button click to call your own API before navigating. Store the response in fox.inputs so it’s available on later screens, or block navigation and show an error if the request fails.

Dynamic navigation logic

Route users to different screens based on multiple conditions evaluated at once. Useful when a single answer isn’t enough to decide the next step.

Third-party tracking

Fire custom events to your analytics tools and ad pixels from any screen. Use fox.inputs.getAll() to include all collected answers in the payload.

Fox API reference

Properties

fox.sandbox
boolean
true in preview mode, false in production. Use to run test-only logic.
fox.locale
string
The user’s browser language code (e.g., "en-US").

Inputs

Read and write the key/value store shared across all screens.

Get a value

Set a value

Get all values

Set email

setEmail() saves the email to the user’s profile, not just as a regular input. Use this for primary email collection.

Get email

Subscribe to a specific input

Subscribe to all inputs

Control which screen the user sees next.

Go to next screen

Go to previous screen

Go to screen by ID

Go to screen by index

Don’t use navigateToScreen(), navigateToId(), navigateToNext(), or navigateToBack(). These are deprecated and exist only for backwards compatibility.

Tracking

Send custom events to connected analytics tools.

Track a custom event

Example

Stripe

Force a Stripe Checkout session to use a specific customer. If the customer ID does not exist, the Checkout session will not appear.

Set customer ID

Event listeners

React to funnel lifecycle events.

On restore replies

Next steps