I have been trying the Sitecore samples to define a custom facet, and it all works if I do it outside from Sitecore. But when I want Sitecore to track the contacts and add data to the custom facet, I get the following error:

18452 23:26:42 ERROR Cannot create tracker.
Exception: System.ArgumentException
Message: The specified type is not a valid facet type.
Parameter name: facetType
Source: Sitecore.Analytics.Model
    at Sitecore.Analytics.Model.Framework.ModelFactory.CreateFacet(Type facetType)
    at Sitecore.Analytics.Model.Framework.Faceted.AddFacet(String name, Type type)

I have set up the facet as:

public class MemberProfile : Facet
    public const string DefaultFacetKey = "MemberProfile";

    public MemberProfile()
    {        }

    public int Zone

This is my model:

public class MemberModel
    public static XdbModel Model { get; } = BuildModel();

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

        // Facets and events here

        modelBuilder.DefineFacet<Contact, MemberProfile>(MemberProfile.DefaultFacetKey);

        return modelBuilder.BuildModel();

and I have serialized it and placed the .json file in xConnect/Data.

  "Name": "MemberModel",
  "Version": "1.0",
  "References": [
      "Name": "XConnect",
      "Version": "1.0"
      "Name": "Sitecore.XConnect.Collection.Model",
      "Version": "9.0"
  "Types": {
    "MemberProfile": {
      "Type": "Facet",
      "BaseType": "Sitecore.XConnect.Facet",
      "ClrType": "XXX.MemberProfile, ModelSerializer, Version=, Culture=neutral, PublicKeyToken=null",
      "Properties": {
        "Zone": {
          "Type": "Int32"
  "Facets": [
      "Target": "Contact",
      "Name": "MemberProfile",
      "Type": "MemberProfile"

Finally, in the Sitecore.XConnect.Client.config I have added:

  <schema name="membermodel" type="Sitecore.XConnect.Client.Configuration.StaticModelConfiguration,Sitecore.XConnect.Client.Configuration">
      <param desc="modeltype">XXX.MemberModel, SEA.Models</param>

I have decompiled the Sitecore.Analytics.Model assembly to look at what is it doing when Framework.ModelFactory.CreateFacet() is called, and it basically tests if my custom facet, which inherits Sitecore.XConnect.Facet, is assignable from Sitecore.Analytics.Model.Framework.IFacet:

if (!typeof (IFacet).IsAssignableFrom(facetType))
    throw new ArgumentException("The specified type is not a valid facet type.", nameof (facetType));

I am obviously doing something wrong or missing something in a config file. I just can't find a solution. Any suggestion is appreciated.


Just wanted to share some details here after this worked. The answer I accepted below helped me figure out how to patch the config, also that I needed to copy the json file to more than one folder. There is also another folder to copy the file into: /xconnect/jobs. At last I was able to store the data into the xdb_collection database:

XConnect Data

But I had the issue of not seeing the custom facet in-session, the data was only set to the database and read from there. So, to make it available in-session, I had to add the faced key to the Sitecore.Analytics.Tracking.config file:

<add name="xconnect" type="Sitecore.Analytics.XConnect.DataAccess.XConnectDataAdapterProvider, Sitecore.Analytics.XConnect">
  <facets hint="raw:AddFacet">
    <facet facetKey="Classification"/>
    <facet facetKey="MemberProfile"/>
  • After doing all the four steps, will the custom facet be visible in the xDB or we will have to set some data in the custom facet only then it will be visible in the DB? Oct 7, 2020 at 12:43
  • 1
    It should store data once you visit the site, unless you changed its default behavior. I got the tracker data in there plus my custom facet, even when browsing anonymously. You might need this to index the data and see it in the experience profile doc.sitecore.com/developers/91/sitecore-experience-platform/en/… Oct 8, 2020 at 14:10
  • Yes, you are right @freethinker6 when I created the contact added the in custom facet then data is visible in the xDB. But, I am not able to see the tracking detail in the experience profile for that contact, what am I missing for that? Even I added the facet key in the Sitecore.Analytics.Tracking.config for the session as you mentioned above. Oct 8, 2020 at 18:06
  • @PrashantTomar I'd say you need to rebuild your index. Please take a look here doc.sitecore.com/developers/91/sitecore-experience-platform/en/… ... also if you are working with anonymous contacts, you might want to index them doc.sitecore.com/developers/91/sitecore-experience-platform/en/… Feb 18, 2021 at 15:32

1 Answer 1


You need to perform the below steps to achieve this:

  1. Create a Custom Facet Model
  2. Register the Custom Facet Model
  3. Deploy Custom Facet model to XDB
  4. Add it to the Sitecore.XConnect.Client.Configuration

In step 3, you need to place .JSON file at two places (You have placed it only one place):

x-connect root path > App_data/Models
x-connect root path > App_data/jobs/continuous/IndexWorker/App_data/Models

In Step 4, update your schema in Sitecore.XConnect.Client.config as below:

<schema name="membermodel" type="Sitecore.XConnect.Client.Configuration.StaticModelConfiguration,Sitecore.XConnect.Client.Configuration" patch:after="schema[@name='collectionmodel']">
  <param desc="modeltype">XXX.MemberModel, SEA.Models</param>

You are missing patch:after="schema[@name='collectionmodel']

Please refer below both the blogs and verify if you missed anything.

Create Custom Facet Model in Sitecore 9

Work with Custom Facet in Sitecore 9

Let me know in case you need further help.

  • 1
    So, steps 1 to 4 are done as explained in the question. I have added the .json file to the locations mentioned. I have followed all the steps in your blog posts, but I still see the error message in the logs. I found this note in Sitecore.Analytics.Model.config: "In case you define custom facets and want GetFacet method to return an object of your custom facet type, make sure that data adapter provider (see sitecore/dataAdapterManager) supports your custom facet type." Any idea how to set that? Jul 26, 2019 at 5:33
  • In Step 3 you need to place JSON file at two places. Jul 26, 2019 at 5:35
  • Please see my first comment edited :) Jul 26, 2019 at 5:37
  • Can you please confirm serialized JSON file is the same name as "MemberModel, 1.0.json"? please delete your serialized file and regenerate it again, as some time it gives "cannot create tracker error" when both custom facet model and serialized model are not same. Jul 26, 2019 at 5:56
  • Added one more step in the answer for the config file 'Sitecore.XConnect.Client.config'. Jul 26, 2019 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.