A volte può essere utile utilizzare un campo con più valori. Prendi in considerazione gli esempi seguenti:
Per gestire i consigli in questi scenari, puoi trasmettere dati con più valori a Target Recommendations e utilizzare operatori speciali con più valori.
Per consentire Recommendations per identificare i dati con più valori, questi devono essere inviati come array JSON, come negli esempi di codice seguenti.
function targetPageParams() {
return {
'entity.id': '123',
'entity.categoryId': '["A", "A:B", "A:B:C", "A:B:C:D"]',
'entity.MultiValueAttribute': '["X", "Y", "Z"]',
'entity.event.detailsOnly': 'true',
'excludedIds": '[123, 3232, 2323, 4344]',
'orderId": '123456',
'orderTotal": '195.32',
'productPurchaseId": '[001,002,003]'
};
}
Per ulteriori informazioni, consulta Implementazione di attributi con più valori in Attributi di entità personalizzati.
## RECSRecommendations Upload File,,,,,,,,,,,,,,,,,,,
## RECS''## RECS'' indicates a Recommendations pre-process header. Please do not remove these lines.,,,,,,,,,,,,,,,,,,,
## RECS,,,,,,,,,,,,,,,,,,,
## RECSUse this file to upload product display information to Recommendations. Each product has its own row. Each line must contain 19 values and if not all are filled a space should be left.,,,,,,,,,,,,,,,,,,,
## RECSThe last 100 columns (entity.custom1 - entity.custom100) are custom. The name 'customN' can be replaced with a custom name such as 'onSale' or 'brand'.,,,,,,,,,,,,,,,,,,,
## RECSIf the products already exist in Recommendations then changes uploaded here will override the data in Recommendations. Any new attributes entered here will be added to the product''s entry in Recommendations.,,,,,,,,,,,,,,,,,,,
## RECSentity.id ,entity.name,entity. categoryId ,entity. message ,entity.thumbnailUrl ,entity.value ,entity.pageUrl ,entity.inventory ,entity.margin ,entity.custom1 ,entity.custom2 ,entity.custom3 ,entity.custom4,entity.custom5,entity.custom6,entity.custom7,entity.custom8,entity.custom9,entity.custom10,
1,Sample Product 1,category1,Save 10%,http://sample.store/products/images/product1_th.jpg,325,http://sample.store/products/product_detail.jsp?productId=1,1000,48,a,"[ ""v1"", ""v2"" ]",, , , , , , , ,
2,Sample Product 2,category1,Save 10%,http://sample.store/products/images/product2_th.jpg,369,http://sample.store/products/product_detail.jsp?productId=2,1000,52,a,"[ ""v1"", ""v2"" ]",, , , , , , , ,
3,Sample Product 3,category1,Save 10%,http://sample.store/products/images/product3_th.jpg,479,http://sample.store/products/product_detail.jsp?productId=3,1000,78,a,"[ ""v1"", ""v2"" ]",,,,,,,,,
4,Sample Product 4,category1,Save 10%,http://sample.store/products/images/product4_th.jpg,409,http://sample.store/products/product_detail.jsp?productId=4,1000,66,a,"[ ""v1"", ""v2"" ]",,,,,,,,,
5,Sample Product 5,category1,Save 10%,http://sample.store/products/images/product5_th.jpg,325,http://sample.store/products/product_detail.jsp?productId=5,1000,45,a,"[ ""v1"", ""v2"" ]",,,,,,,,,
Quando un attributo di entità, un attributo di profilo o un parametro mbox viene fornito come multivalore in base al formato precedente, Recommendations deduce automaticamente che il campo ha più valori.
I seguenti operatori sono disponibili per l’utilizzo con attributi di entità, profili e mbox con più valori:
Il supporto per la corrispondenza dinamica ad attributi con più valori è attualmente disponibile solo nei criteri quando si utilizza una regola di corrispondenza degli attributi di profilo o di parametro (mbox) quando si confronta un singolo valore a sinistra con un valore multiplo a destra. Gli attributi con più valori non sono attualmente supportati nelle promozioni, nella corrispondenza degli attributi di entità o per gli elenchi sul lato sinistro delle regole di inclusione.
Supponiamo di voler evitare che vengano consigliati film degli ultimi dieci guardati dall’utente. Innanzitutto, scrivi uno script di profilo denominato user.lastWatchedMovies
per tenere traccia degli ultimi dieci film visualizzati come array JSON. Quindi, puoi escludere gli elementi utilizzando la seguente regola di inclusione:
`Profile Attribute Matching`
`id - is not contained in list - user.lastWatchedMovies`
Rappresentazione API JSON della regola di inclusione:
{
"attribute": "id",
"operation": "isNotContainedInList",
"source": {
"name": "user.lastWatchedMovies",
"type": "PROFILE"
}
}
Supponiamo di voler consigliare biglietti solo per concerti se la band che suona è una delle band preferite dell'utente. Innanzitutto, assicurati di disporre di una variabile di profilo denominata profile.favoriteBands
che contiene i gruppi preferiti dell’utente. Quindi, assicurati che il catalogo includa un attributo entity.artistPerforming
che include l'artista che si esibisce nel concerto. Quindi, puoi utilizzare la seguente regola di inclusione:
`Profile Attribute Matching`
`artistPerforming - is contained in list - profile.favoriteBands`
Rappresentazione API JSON della regola di inclusione:
{
"attribute": "artistPerforming",
"operation": "isContainedInList",
"source": {
"name": "profile.favoriteBands",
"type": "PROFILE"
}
}
I criteri che utilizzano regole di filtro con più valori, come tutti i criteri, possono essere creati tramite API Adobe I/O. Esempio di chiamata API per creare un criterio in cui l’attributo di entità id
è contenuto nell’elenco dei parametri mbox favorites
è fornito qui:
curl -X POST \
https://<serverhost>/api/recs/<client>/criteria/item \
-H 'Accept: application/vnd.adobe.target.v1+json' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'User-Agent: <from API client>' \
-H 'X-Target-user-email: <email address>' \
-H 'cache-control: no-cache' \
-d '{
"name": "viewed criteria",
"criteriaTitle": "test title",
"type": "VIEWED_CF",
"key": "CURRENT",
"daysCount": "TWO_WEEKS",
"aggregation": "NONE",
"backupDisabled": false,
"partialDesignAllowed": true,
"configuration": {
"inclusionRules": [
{
"attribute": "id",
"operation": "isContainedInList",
"source": {
"name": "mbox.favorites",
"type": "MBOX"
}
}
]
}
}'
Questo viene associato a JavaScript sulla pagina per passare nei contenuti preferiti:
<!-- pass in the value of mbox parameter “favorites” as JSON array -->
<script type="text/javascript">
mboxCreate('myMbox','entity.id=<key>','favorites=["a","b","c"]');
</script>