For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Resources
Get started
ReferenceChangelog
ReferenceChangelog
  • Browser API
    • wf.ready()
  • Consent Management
    • Get consent status
    • Allow user tracking
    • Deny user tracking
  • Optimize
    • Quickstart
    • Variations
    • Custom attributes
  • Custom Goals
    • On-site conversions
      • sendEvent()
    • Off-site conversions
  • Data Exports
    • Data destinations
    • Data schema
  • Additional Resources
    • Support Documentation
LogoLogo
Resources
Get started
On this page
  • wf.sendEvent(eventName, options?)
  • Syntax
  • Parameters
  • Examples
  • Basic usage
  • With a value
  • Recording dynamic values
  • Returns
  • FAQs
Custom GoalsOn-site conversions

sendEvent()

Was this page helpful?
Previous

Off-site conversions

Next
Built with

wf.sendEvent(eventName, options?)

Trigger a custom goal to track conversions on your Webflow site.

Create a custom goal first

Before calling wf.sendEvent(), create a custom goal. Then, pass the eventName from the custom goal to this method.

Syntax

1wf.sendEvent(eventName: string)
1wf.sendEvent(eventName: string, options: { value: number | string })

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 a value property 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., 10 is valid, -10 is not)
  • Can include up to two decimal places (e.g., 10, 10.5, 10.50)
  • Must not include currency symbols (e.g., 10.50 is valid, $10.50 is not)

To ensure two-decimal accuracy when working with dynamic values:

1Number.parseFloat(rawValue).toFixed(2);

Examples

Basic usage

Track a simple on-site conversion:

1wf.ready(function() {
2 wf.sendEvent('form_submitted');
3});

With a value

Track an on-site conversion with an associated monetary value:

1wf.ready(function() {
2 wf.sendEvent('purchase', { value: 149.99 });
3});

Recording dynamic values

Track values that vary based on user action, such as a shopping cart total:

1wf.ready(function() {
2 var eventName = 'purchase';
3 var price = document.getElementById('total_price').value;
4 wf.sendEvent(eventName, { value: price });
5});

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
  • Used the exact eventName (case-sensitive) from the custom goal in your wf.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.