Dati del profilo utente
I dati possono essere archiviati in un Profilo utente che può poi essere utilizzato in tutto il sistema. Questi attributi possono includere Attributi Semantici dell'Utente.
Le operazioni sui dati del Profilo utente utilizzano il tipo di messaggio userDataOps
.
Operazioni
Il parametro operations
accetta un array di operazioni. Possono essere del seguente tipo:
- set - imposta un attributo del Profilo su un dato valore
- setOnce - imposta un attributo del Profilo su un dato valore se attualmente non esiste
- unset - rimuove un attributo del Profilo
- increment - incrementa un attributo del Profilo di un dato importo intero
È possibile inviare contemporaneamente tutte le operazioni necessarie, e possono essere di più di un tipo.
Scadenza
Sia set
che setOnce
consentono di fornire una proprietà expiresOn
. Questa deve essere un numero intero di tempo epoch UTC in millisecondi.
Set
Utilizzare questo per impostare un attributo in un Profilo.
Esempio
Questo esempio imposta l'attributo favoriteColor
su red
. Questa proprietà del Profilo scadrà verso l'inizio del 2024.
{
"type": "userDataOps",
// le operazioni
"operations": [{
"type": "set",
"key": "favoriteColor",
"value": "red",
"expiresOn": 1704139200000
}],
// proprietà generali del messaggio
"writeKey": "<WRITE_KEY>",
"messageId": "213d7f53-ffac-4a58-a20b-5d609455d64c",
"timestamp": "2022-11-15T04:31:44Z",
"userId": "5.wBOQ7hKNVgIUcJn5IbX.1670273082",
"sessionId": "28eef5c8-1098-4f76-abe9-58a921cabfaf",
"pageId": "eca34e0f-4802-4fa4-8db1-11c727839dbd"
"context": {
"page": {
"url": "https://www.weather-station.com/",
"path": "/",
"referrer": "",
"title": "Weather Station - Get Weather"
},
}
}
Set Once
Utilizzare questo per impostare un attributo in un Profilo solo se non è ancora stato impostato.
Esempio
Questo esempio, se eseguito dopo l'esempio set
, non modificherà l'attributo del Profilo poiché il valore è già stato impostato.
{
"type": "userDataOps",
// le operazioni
"operations": [{
"type": "setOnce",
"key": "favoriteColor",
"value": "green"
}],
// proprietà generali del messaggio
"writeKey": "<WRITE_KEY>",
"messageId": "213d7f53-ffac-4a58-a20b-5d609455d64c",
"timestamp": "2022-11-15T04:31:44Z",
"userId": "5.wBOQ7hKNVgIUcJn5IbX.1670273082",
"sessionId": "28eef5c8-1098-4f76-abe9-58a921cabfaf",
"pageId": "eca34e0f-4802-4fa4-8db1-11c727839dbd"
"context": {
"page": {
"url": "https://www.weather-station.com/",
"path": "/",
"referrer": "",
"title": "Weather Station - Get Weather"
},
}
}
Unset
Utilizzare questo per rimuovere un attributo da un Profilo.
Esempio
Questo esempio ha rimosso l'attributo favoriteColor
.
{
"type": "userDataOps",
// le operazioni
"operations": [{
"type": "unset",
"key": "favoriteColor"
}],
// proprietà generali del messaggio
"writeKey": "<WRITE_KEY>",
"messageId": "213d7f53-ffac-4a58-a20b-5d609455d64c",
"timestamp": "2022-11-15T04:31:44Z",
"userId": "5.wBOQ7hKNVgIUcJn5IbX.1670273082",
"sessionId": "28eef5c8-1098-4f76-abe9-58a921cabfaf",
"pageId": "eca34e0f-4802-4fa4-8db1-11c727839dbd"
"context": {
"page": {
"url": "https://www.weather-station.com/",
"path": "/",
"referrer": "",
"title": "Weather Station - Get Weather"
},
}
}
Incremento
Utilizzare questo per incrementare un valore su un attributo del Profilo.
WARNING
Se esiste già un attributo con lo stesso nome e non è un numero intero, il valore verrà comunque impostato su 1
. Questo è vero anche se il valore è una stringa "1"
anziché il valore effettivo 1
. Inoltre, i valori float come 10.5
verranno reimpostati su 1
alla prima chiamata di incremento.
Esempio
Questo esempio incrementerà l'attributo numberOfLoginAttempts
di 1.
{
"type": "userDataOps",
// le operazioni
"operations": [{
"type": "increment",
"key": "numberOfLoginAttempts",
"value": 1
}],
// proprietà generali del messaggio
"writeKey": "<WRITE_KEY>",
"messageId": "213d7f53-ffac-4a58-a20b-5d609455d64c",
"timestamp": "2022-11-15T04:31:44Z",
"userId": "5.wBOQ7hKNVgIUcJn5IbX.1670273082",
"sessionId": "28eef5c8-1098-4f76-abe9-58a921cabfaf",
"pageId": "eca34e0f-4802-4fa4-8db1-11c727839dbd"
"context": {
"page": {
"url": "https://www.weather-station.com/",
"path": "/",
"referrer": "",
"title": "Weather Station - Get Weather"
},
}
}