Sometimes the algorithms provided by Recommendations are not able to surface particular items you would like to promote. In such a situation, custom criteria provide a way for you to deliver a specific set of recommended items for a given key item or category. You define the mapping between the key item or category and the recommended items, and import that mapping as a custom criteria. This process is described in the custom criteria documentation. As noted in that documentation, you are able to create, edit, and delete custom criteria through the Target user interface (UI). However, Target also provides a set of Custom Criteria APIs that allow for more detailed management of your custom criteria.
Follow this usage guideline for custom criteria:
Either do everything (create, edit, delete) for a given custom criteria using the APIs, or else do everything (create, edit, delete) using the UI. Managing your custom criteria through a combination of the UI and the API may lead to conflicting information or unexpected results. For example, creating a custom criteria in the UI but then editing it via API will not reflect your updates in the UI, even though it will be updated in the backend, as visible via the API.
To create custom criteria using the Create Custom Criteria API, the syntax is:
Custom criteria created using the Create Custom Criteria API, as described in this exercise, will appear in the UI, where they will persist. You will not be able to edit or delete them from the UI. You may edit or delete them via API, but either way, they will continue to appear in the Target UI. To maintain the option of editing or deleting from the UI, create the custom criteria using the UI per the documentation, as opposed to using the Create Custom Criteria API.
Only proceed with this tutorial after you have read the warning above and are comfortable creating new custom criteria that cannot subsequently be deleted from the UI.
API_KEY for Create custom criteria reference the Postman environment variables established earlier. Use the image below for comparison.
Add your Body as raw JSON that defines the location of your custom criteria CSV file. Use the example provided in the Create Custom Criteria API documentation as a template, supplying your
environmentId and other values as necessary. For this example, we use LAST_PURCHASED as the key.
Send the request and observe the response, which contains the details of the custom criteria you just created.
To verify your custom criteria has been created, navigate within Adobe Target to Recommendations > Criteria and search for your criteria by name, or use the List Custom Criteria API in the next step.
In this case, we have an error. Let’s investigate the error by examining the custom criteria more closely, using the List Custom Criteria API.
To retrieve a list of all your custom criteria along with details for each, use the List Custom Criteria API. The syntax is:
API_KEYas before, and send the request. In the response, note the custom criteria ID, as well as details regarding the error message noted earlier.
In this case, the error occurred because the server information is incorrect, meaning Target is unable to access the CSV file containing the custom criteria definition. Let’s edit the custom criteria to correct this.
To change the details of a custom criteria definition, use the Edit Custom Criteria API. The syntax is:
API_KEY, as before.
Specify the criteria ID of the (single) custom criteria you would like to edit.
In the Body, supply updated JSON with the correct server information. (For this step, specify FTP access to a server you can access.)
Send the request and note the response.
Let’s verify the success of the updated custom criteria, using the Get Custom Criteria API.
To view custom criteria details for a specific custom criteria, use the Get Custom Criteria API. The syntax is:
Using the criteria ID noted earlier, delete your custom criteria, using the Delete Custom Criteria API. The syntax is:
Specify the criteria ID of the (single) custom criteria you would like to delete. Click Send.
Verify the criteria has been deleted using Get Custom Criteria.
In this case, the expected 404 error indicates the deleted criteria cannot be found.
As a reminder, the criteria will not be removed from the Target UI even though it was deleted, because it was created using the Create Custom Criteria API.
Congratulations! You are now able to create, list, edit, delete, and get details on custom criteria, using the Recommendations API. In the next section, you will use the Target Delivery API to retrieve recommendations.