---
schema_version: "1"
id: 175550abd5b1a1e43ce3fbfa41da6d8b56b5fd86ad27a2118cc43828b441b1c2
title: Custom Event (<tracking:custom-event/>)
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/anypoint-code-builder/acb-component-custom-event.md
canonical_url: https://docs.mulesoft.com/anypoint-code-builder/acb-component-custom-event
source_site: docs.mulesoft.com
content_type: documentation
content_hash: b50f18d28aadbb70d66bae1d1cb4ac104fe50e6a77e2e73493c5f1c98e32ee20
description: MuleSoft Documentation Site
latest: true
---
---
product: Anypoint Code Builder
version: master
---

# Custom Event (<tracking:custom-event/>)

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Add metadata and Key Performance Indicators (KPIs) to your flow through a custom business event.

For your KPIs, use names that are easy to search for in the Anypoint Runtime Manager interface, and
use a representative value, which can be any Mule expression:

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Expression / Value</th></tr></thead><tbody><tr><td><div><div><p><code>employee-id</code></p></div></div></td><td><div><div><p><code>#[payload['ID']]</code></p></div></div></td></tr><tr><td><div><div><p><code>employee-email</code></p></div></div></td><td><div><div><p><code>#[payload['Email']]</code></p></div></div></td></tr><tr><td><div><div><p><code>employee-git-id</code></p></div></div></td><td><div><div><p><code>#[payload['GITHUB_ID']]</code></p></div></div></td></tr><tr><td><div><div><p><code>price</code></p></div></div></td><td><div><div><p><code>700</code></p></div></div></td></tr><tr><td><div><div><p><code>price-after-discount</code></p></div></div></td><td><div><div><p><code>#[vars.price]</code></p></div></div></td></tr><tr><td><div><div><p><code>order-id</code></p></div></div></td><td><div><div><p><code>#[payload.order.header.orderID]</code></p></div></div></td></tr></tbody></table>

## Component XML

This component supports the following XML structure:

```xml
<tracking:custom-event
    event-name=""
    doc:name="Custom event"
    doc:id="akfkag" />
```

Custom Business Event (`<tracking:custom-event/>`) attributes are configurable through the UI and
XML.

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Attribute Name</th><th>Attribute XML</th><th>Description</th></tr></thead><tbody><tr><td><p><strong>Custom event</strong> (default)</p></td><td><p><code>doc:name</code></p></td><td><div><div><p>Editable name for the component to display in the canvas.</p></div></div></td></tr><tr><td><p>N/A</p></td><td><p><code>doc:id</code></p></td><td><div><div><p>Automatically generated identifier for the component.</p></div></div></td></tr><tr><td><p><strong>Event name</strong></p></td><td><p><code>event-name</code></p></td><td><div><div><p>Name of the event to track.</p></div></div></td></tr><tr><td><p><strong>Inherits</strong></p></td><td><p><code>inherits</code></p></td><td><div><div><p>N/A</p></div></div></td></tr><tr><td><p><strong>Meta data</strong></p></td><td><p><code>metaData</code></p></td><td><div><div><p>N/A</p></div></div></td></tr><tr><td><p><strong>Target Variable</strong></p></td><td><p><code>target</code></p></td><td><div><div><p>Name of the variable in which you want to store message data. Names can only include numbers, characters, and underscores. For example, hyphens are not allowed in the name. See <a href="https://docs.mulesoft.com/mule-runtime/latest/target-variables">Enrich Data with Target Variables</a> in the Mule documentation.</p></div></div></td></tr><tr><td><p><strong>Target Value</strong></p></td><td><p><code>targetValue</code></p></td><td><div><div><p>Value of the data to store in the target variable. By default, the value is the message payload (payload). The field accepts any value that a variable accepts: any supported data type, DataWeave expressions, the keywords <code>payload</code>, <code>attributes</code>, and <code>message</code>, but not the keyword <code>vars</code>. See <a href="https://docs.mulesoft.com/mule-runtime/latest/target-variables">Enrich Data with Target Variables</a> in the Mule documentation.</p></div></div></td></tr></tbody></table>

The child element `<tracking:meta-data/>` attributes are configurable through the UI and XML.

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Attribute Name</th><th>Attribute XML</th><th>Description</th></tr></thead><tbody><tr><td><p>N/A</p></td><td><p><code>key</code></p></td><td><div><div><p>Name of the KPI.</p></div></div></td></tr><tr><td><p>N/A</p></td><td><p><code>value</code></p></td><td><div><div><p>Value of the KPI.</p></div></div></td></tr></tbody></table>

## Example

The following example configures a tracking event and a KPI.

```xml
<tracking:custom-event doc:name="Custom Business Event" event-name="New order">
	<tracking:meta-data key="order-id" value="#[payload.order.header.orderID]" />
</tracking:custom-event>
```

## See Also

- [Business Events](https://docs.mulesoft.com/mule-runtime/latest/business-events)
