---
title: "Create a custom outcome model"
slug: "create-a-custom-outcome-model"
abstract: "How to create definition items and custom outcome models as well as how to define the custom facet in the model and how to use the custom outcome model."
---
# Create a custom outcome model

This topic describes how to create a custom outcome named `CarPurchaseOutcome` that inherits `Outcome`, and assumes the following requirements:

- The `CarPurchaseOutcome` outcome will be used with a single definition item
- The `CarPurchaseOutcome` has two additional mandatory properties named `Make` and `Model`

<details>
<summary><h2>Create definition items</h2></summary>

1. Open the Sitecore Content Editor.
2. Go to /sitecore/system/Marketing Control Panel/Outcomes.
3. Right-click on the Outcomes item and select **Insert** > **Outcome**. 
4. Enter an item name when prompted - for example, Car Purchase.
5. Select the newly created definition, then click the **Review** tab, then select **Deploy**. This publishes the definition to the web database and deploys it to the Reference Data Service database.

</details>

<details>
<summary><h2>Create custom outcome model</h2></summary>

Create a new class named `CarPurchaseOutcome` that inherits the `Outcome` class. This class has a fixed definition ID, which means it cannot be instantiated with any other definition ID.

```csharp
using Sitecore.XConnect;
using System;

namespace Documentation
{
    public class CarPurchaseOutcome : Outcome
    {
        public static Guid CarPurchaseEventDefinitionId { get; } = new Guid("2b7e9e7e-f7ac-4ac2-8f8e-26a9c8644b23");

        public CarPurchaseOutcome(DateTime timestamp, string currencyCode, decimal monetaryValue, string model, string make)
            : base(CarPurchaseEventDefinitionId, timestamp, currencyCode, monetaryValue)
        {
            Model = model;
            Make = make;
        }

        public string Model { get; set; }
        public string Make { get; set; }
    }
}

```

</details>

<details>
<summary><h2>Define custom facet in model</h2></summary>

Define the new outcome in your collection model using the `.DefineEventType` method. In the following example, the outcome model has been added to a model named `SampleModel`. If you are using the model in a Sitecore context, the model class must be [registered in the client configuration file](https://doc.sitecore.com/xp/en/developers/93/sitecore-experience-platform/create-a-custom-model.html "Create a custom model").

```csharp
using Sitecore.XConnect;
using Sitecore.XConnect.Schema;

namespace Documentation
{
    public class SampleModel
    {
        public static XdbModel Model { get; } = SampleModel.BuildModel();

        private static XdbModel BuildModel()
        {
            XdbModelBuilder modelBuilder = new XdbModelBuilder("SampleModel", new XdbModelVersion(0, 1));

            modelBuilder.ReferenceModel(Sitecore.XConnect.Collection.Model.CollectionModel.Model);
            modelBuilder.DefineEventType<CarPurchaseOutcome>(false);

            return modelBuilder.BuildModel();
        }
    }
}

```

> [!warning]
> If you do not register your outcome model, you cannot use it. You will get errors such as ‘The type of this instance does not correspond to any type in the schema’.

</details>

<details>
<summary><h2>Use custom outcome model</h2></summary>

Use the xConnect Client API to [add your outcome to an interaction](https://doc.sitecore.com/xp/en/developers/93/sitecore-experience-platform/add-interaction-events.html "Add interaction events"). The following example demonstrates how to instantiate the custom outcome:

```text
var purcaseOutcome = new CarPurchaseOutcome(DateTime.UtcNow, "DKK", 60000, "MX-5", "Mazda");

```

</details>

<details>
<summary><h2>Use custom outcome model with the tracker</h2></summary>

To use a custom outcome model within the tracker, you must create an event conversion pipeline processor. For more information, see [Triggering custom events](https://doc.sitecore.com/xp/en/developers/93/sitecore-experience-platform/triggering-custom-events.html "Triggering custom events").

</details>