Browser API
The Browser API lets you control Webflow Analyze and Optimize features directly from your site’s JavaScript. Use it to manage consent, track experiments, and personalize user experiences.
Analyze or Optimize required
The Browser API is available only on sites with Webflow Analyze or Optimize enabled and tracking turned on. To enable tracking, open the Insights tab. Under Settings, click Tracking, then turn on the Start tracking visitor data toggle.
What you can do with the Browser API
Manage user consent and privacy preferences in real time
Send optimization variations from experiments to third-party tools
Set custom attributes based on user behavior and data
Track on-site and off-site conversions with custom goals
Getting started
Choose where to add your code
You can use the Browser API by adding JavaScript in one of two ways:
-
Directly in your site Add a script before the closing
</head>tag using Webflow’s custom code settings. Best for simple use cases. -
With Google Tag Manager (or similar) Add a script as a custom tag. Recommended for advanced tracking or integrations.
Wait for the API to be ready
Wrap your code in wf.ready() to ensure the API has loaded before you call any methods:
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 with Analyze and Optimize enabled, 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.