View conversion events in a rule
Learn how to view and trigger conversion events in a rule using Optimize and custom code components.
If Optimize is enabled, you can view conversion rates in your rule.
For further information on Optimize, see the Optimize – Zephr Journey topic.
You can trigger a conversion event, such as a registration successful event, using code in your custom component block.
For example, the following code creates an HTML component:
<script>
// JavaScript here
fetch('/zephr/public/rule-outcomes/v1/conversions', {method: 'POST', headers: { 'Content-Type': 'application/json' }, body: `{
"conversion": "REGISTERED", // or "CUSTOMER", if it's a payment form
"ruleId": "{{ruleId}}",
"outcomeId": "{{outcomeId}}"
`})
// JavaScript here
</script>
As you can see, the HTML is contained in the JavaScript, which registers the outcome.