Configure custom xConnect models
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.
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:
-
In the
sitecoreruntime
folder, create a new folder which has the same name as the current environment. The default isProduction
. If you are configuring your development environment, for example, it should beDevelopment
. -
Copy the assembly into the environment folder
sitecoreruntime\<environment>
. -
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
. -
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:
-
In the
config
folder, add a new file and name it, for example,eventMappings.xml
. -
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 calledcg
: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:
{
"type":"cg",
"DefinitionId":"ffb4e611-a73d-4a95-b20a-811d295bdfff",
"Timestamp":"2018-08-09T11:54:56.853Z",
"TrackingInteractionId":"6d7f175a-d328-4729-bf35-599b06acc19e"
}