sendEvent()
wf.sendEvent(eventName, options?)
Trigger a custom goal event to track conversions on your site.
Create a custom goal first
Before calling wf.sendEvent(), create a custom goal first. The eventName you create is what you’ll pass to this method.
Syntax
Parameters
-
eventName (required):
string— The name of the custom event you created in your custom goal. Must be 40 printable ASCII characters or fewer, and cannot contain spaces. -
options (optional):
{ value: number | string }— An object containing avalueproperty for tracking monetary or numeric values with the conversion.
Value formatting
When including a value, it must meet these conditions:
- Can be a string or number
- Must not be negative (e.g.,
10is valid,-10is not) - Can include up to two decimal places (e.g.,
10,10.5,10.50) - Must not include currency symbols (e.g.,
10.50is valid,$10.50is not)
To ensure two-decimal accuracy when working with dynamic values:
Use with Google Tag Manager
If you’re using Google Tag Manager (GTM) and already have triggers set up for actions you want to track, you can create a custom HTML tag that calls wf.sendEvent():
Then attach this tag to an existing GTM trigger (e.g., a “Form Submission” trigger you’re already using for other tracking).
Examples
Basic usage
Track a simple on-site conversion:
With a value
Track an on-site conversion with an associated monetary value:
Recording dynamic values
Track values that vary based on user action, such as a shopping cart total:
Returns
This method doesn’t return a value. The event is sent to Webflow and recorded in your optimization results.
FAQs
Why isn't my custom goal showing up in Analyze/Optimize?
Make sure you’ve:
- Created the custom goal in Webflow, following the instructions here: Create a custom goal
- Used the exact
eventName(case-sensitive) in yourwf.sendEvent()call - Wrapped your code in
wf.ready()to ensure the Browser API is available
How quickly do on-site conversion goals appear in my Analyze/Optimize dashboard?
On-site conversion events are recorded in real time and should appear in your Analyze/Optimize dashboard within approximately 15 - 30 minutes.