Introduction
The Browser API provides JavaScript methods to interact with Webflow features directly in a visitor’s browser. This API is automatically available through the global wf
namespace on all Webflow sites.
Current features
Webflow Optimize
The Browser API provides methods to integrate with Webflow Optimize. You can use Optimize-specific methods to track variations and personalize experiences. See the Webflow Optimize documentation for more information.
Send optimization variations from experiments to third-party tools
Set custom attributes to personalize experiences based on user behavior and data
Getting started
Decide where to add your code
You can add code to interact with the Browser API in one of two ways:
-
Add code directly to your site
- Place a script in before the closing
</head>
tag of your site using Webflow’s custom code feature - This is the simplest approach for basic implementations
- Place a script in before the closing
-
Use Google Tag Manager or a similar tool
- Add a script when configuring a custom tag
- Recommended for more complex implementations or when using other tracking tools
Check if the Browser API is ready
The Browser API is available through the global wf
namespace. The API includes a definition for wf.ready()
, a function that enables you to register callbacks to trigger as soon as the Browser API becomes available to call.
Before using any API methods, you should wrap your code in wf.ready()
to ensure the Browser API has fully loaded and initialized. This prevents errors that could occur if you try to call API methods before they’re available.
For example:
No installation required
The Browser API is automatically included on all Webflow sites and handles loading the necessary code in an optimized way to minimize impact on page performance.Add callbacks to your code
Now you can start adding callbacks inside of wf.ready()
. Currently, the Browser API offers methods to interact with Webflow Optimize. See the Webflow Optimize API documentation for more information.
FAQs
What is the Browser API?
The Browser API is a JavaScript API that allows you to interact with Webflow features directly in the browser. It provides methods to retrieve Optimize variations, set custom attributes, and handle other Webflow features.
How do I add the Browser API to my site?
The Browser API is automatically included on all Webflow sites and handles loading the necessary code in an optimized way to minimize impact on page performance.
How do I use the Browser API?
The Browser API is available through the global wf
object in your browser. You can access the API by adding a script using custom code on your sites and pages or through external services that load scripts on your site like Google Tag Manager.
The API can be called from any JavaScript code running on your site.