Configure custom xConnect models

Current version: 9.1

This section applies to both the collection service and the processing service.

By default, .NET core does not load all assembly files in the application directly. Whenever you add a configuration that includes a custom type name, for example, to register a custom xConnect model, you must configure the application to load the assembly containing the type.

Note

The custom xConnect model is deployed as an assembly, not as a JSON file as is done on the xConnect servers.

To configure the xConnect model in a Sitecore host application:

  1. In the sitecoreruntime folder, create a new folder which has the same name as the current environment. The default is Production. If you are configuring your development environment, for example, it should be Development.

  2. Copy the assembly into the environment folder sitecoreruntime\<environment>.

  3. You can now add a configuration to extend the xConnect configuration and include the custom xConnect model. Inside the config folder, add a file and name it, for example, xConnectModels.xml.

  4. Inside the xConnectModels.xml file, add the following content:

    RequestResponse
    <Settings>
        <XConnect>
            <Models>
                <Custom>
                    <TypeName>UTDemo.XConnectExtensions.CampaignModel, UTDemo.XConnectExtensions</TypeName>
                    <PropertyName>Model</PropertyName>
                </Custom>
            </Models>
        </XConnect>
    </Settings>

    This code registers the custom xConnect model provided by the UTDemo.XConnectExtensions.CampaignModel class.

To allow callers to use a custom xConnect model event, you must provide a mapping for the event. The default mappings are provided in the \sitecore\Sitecore.Tracking\Config\config.xml file. You must add your mappings in a patch file:

  1. In the config folder, add a new file and name it, for example, eventMappings.xml.

  2. Add your custom event mappings to the config file using the same node structure as the \sitecore\Sitecore.Tracking\Config\config.xml file. This example adds a custom event type called cg:

    RequestResponse
    <Settings>
        <Sitecore.Tracking>
            <TypeMappings>
                <cg>UTDemo.XConnectExtensions.CustomGoal, UTDemo.XConnectExtensions</cg>
            </TypeMappings>
        </Sitecore.Tracking>
    </Settings>

Callers can now set the type of an event to cg to register that event type. For example, a client can send this HTTP request:

RequestResponse
{
"type":"cg",
"DefinitionId":"ffb4e611-a73d-4a95-b20a-811d295bdfff",
"Timestamp":"2018-08-09T11:54:56.853Z",
"TrackingInteractionId":"6d7f175a-d328-4729-bf35-599b06acc19e"	
}

Do you have some feedback for us?

If you have suggestions for improving this article,