Optimize for non-Webflow sites

Create a goal event

Updated

Define the actions that trigger conversions in custom goals.

Goal events are used by custom goals to define what counts as a conversion. Each goal event type represents a specific action — a click, page view, or API custom event — that you can track. Custom goals listen for one or more goal events and count a conversion whenever one is triggered. You can reuse the same goal event in multiple custom goals.

Goal event types

There are three types of goal events you can create:

  • Click — tracks when a visitor clicks specific page elements. You can define the page element with a CSS selector and optional JavaScript.
  • Page view — tracks when a visitor loads a specific page. You can use JavaScript to add conditions — for example, checking whether a page element is visible or a certain variable is set.
  • Custom JavaScript — leverages the sendEvent() API to track custom events. You write custom JavaScript on your site pages to define what the trigger is. You can also optionally include a value when calling the event.

Create a click event

Open your Optimize site in Webflow, then:

  1. Click Components in the Navigation panel
  2. Click the Events tab > New event
  3. Enter an event name
  4. Select A click for Event Type
  5. Choose a page definition for Goal Event Page
  6. Enter a Selector value that matches the element
  7. Optional: Enter JavaScript that evaluates to true or false if you want to refine when the click should count
  8. Click Save

Good to know

If your goal includes JavaScript, it runs when the click occurs. The event only triggers if your code returns true.

Create a page view event

Open your Optimize site in Webflow, then:

  1. Click Components in the Navigation panel
  2. Click the Events tab > New event
  3. Enter an event name
  4. Select A page view for Event Type
  5. Choose a page definition for Goal Event Page
  6. Optional: Enter JavaScript that evaluates to true or false if you want to refine when the click should count
  7. Click Save

Good to know

If your goal includes JavaScript, it runs when the page loads. The event only triggers if your code returns true.

Create custom JavaScript event (API)

Important

Requires the sendEvent() API. Your event apiName must match the apiName used in sendEvent().

Open your Optimize site in Webflow, then:

  1. Click Components in the Navigation panel
  2. Click the Events tab > New event
  3. Enter an event name
  4. Select A custom JavaScript event for Event Type
  5. Enter an apiName in the API field
  6. Click Save