Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
Per ulteriori informazioni sull'approccio generale alla configurazione delle notifiche push in Customer Insights - Journeys, visita la panoramica sulla configurazione delle notifiche push.
Per abilitare le notifiche push in Customer Insights - Journeys, devi completare i seguenti passaggi:
- Configurazione dell'applicazione delle notifiche push
- Mapping utente per notifiche push
- Registrazione del dispositivo per le notifiche push
- Ricevere notifiche push sui dispositivi
- Report di interazione per notifiche push
Per generare rapporti sui tassi di apertura, l'applicazione deve inviare questi dati a Customer Insights - Journeys.
Importante
Per tenere traccia dei collegamenti aperti dai destinatari nelle notifiche, è necessario raccogliere il consenso al tracciamento dei clienti. Scopri di più sulle strategie per la raccolta del consenso dei clienti in Customer Insights - Journey: Panoramica sulla gestione del consenso
Inviare eventi a Customer Insights - Percorsi
URL della richiesta:
POST {PublicEndpoint}api/v1.0/orgs/<orgId>/pushdatareceiver/events
{
"TrackingId": "00000000-0000-0000-0000-000000000000",
"DeviceToken": "%DeviceToken",
"PushNotificationStatus": 1
}
Restituisce: 202 se la richiesta è corretta, 400 altrimenti
Nome | Descrizione |
---|---|
ID di tracciamento | Ogni notifica ha un identificatore di tracciamento nei suoi dati. Questo identificatore deve essere inviato per il monitoraggio degli eventi. |
DeviceToken | Token univoco per il dispositivo mobile che registra l'evento. |
PushNotificationStatus | Codice di stato per l'evento. "1" viene restituito per l'evento aperto. |
orgId | Identificatore dell'organizzazione Customer Insights - Journeys. |
Esempio di codice Swift per inviare eventi in iOS
func createInteraction(typeInteraction: Int, trackingId: String) {
if !trackingId.isEmpty || trackingId == "00000000-0000-0000-0000-000000000000" {
return
}
let orgId = UserDefaults.standard.string(forKey: "organizationId2")
let endP = UserDefaults.standard.string(forKey: "endpoint2")
if orgId == nil || endP == nil {
return
}
let url = URL(
string: String(
format: "https://%@/api/v1.0/orgs/%@/pushdatareceiver/events", endP ?? "", orgId ?? ""))!
let session = URLSession.shared
// now create the URLRequest object using the url object
var request = URLRequest(url: url)
request.httpMethod = "POST" //set http method as POST
// add headers for the request
request.addValue("application/json", forHTTPHeaderField: "Content-Type") // change as per server requirements
request.addValue("application/json", forHTTPHeaderField: "Accept")
do {
// convert parameters to Data and assign dictionary to httpBody of request
let deviceToken = UserDefaults.standard.string(forKey: "deviceToken")
let jsonBodyDict = [
"PushNotificationStatus": String(typeInteraction), "DeviceToken": deviceToken,
"TrackingId": trackingId,
]
request.httpBody = try JSONSerialization.data(
withJSONObject: jsonBodyDict, options: .prettyPrinted)
} catch let error {
print(error.localizedDescription)
return
}
// create dataTask using the session object to send data to the server
let task = session.dataTask(with: request) { data, response, error in
if let error = error {
print("Post Request Error: \(error.localizedDescription)")
return
}
// ensure there is valid response code returned from this HTTP response
guard let ttpResponse = response as? HTTPURLResponse,
(200...299).contains(httpResponse.statusCode)
else {
print("Invalid Response received from the server")
return
}
print("Interaction creation successful.")
}
// perform the task
task.resume()
}
Esempio di codice Java per inviare eventi in Android
Parte 1: genera il payload
EventTrackingContract:
public String toJsonString() {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("PushNotificationStatus", mEvent.toString());
jsonObject.put("DeviceToken", mDeviceToken);
jsonObject.put("TrackingId", trackingId);
} catch (JSONException e) {
Log.d(LOG_TAG, "Json exception while creating event tracking contract: " + e.getMessage());
}
return jsonObject.toString();
}
EventTypeEnum:
public enum EventType {
Opened(1);
}
Parte 2: HttpClient per l'invio dell'evento al server
AsyncTask.execute(new Runnable() {
@Override
public void run() {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
String hostname = sharedPreferences.getString(HOST_NAME, "");
String organizationId = sharedPreferences.getString(ORGANIZATION_ID, "");
final HashMap<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
final EventTrackingContract eventTrackingContract = new EventTrackingContract(event);
Log.d(TAG, eventTrackingContract.toJsonString());
String response = HttpClientWrapper.request(String.format("https://%s/api/v1.0/orgs/%s/pushdatareceiver/events"
, hostname, organizationId, trackingId),
"POST", headers, eventTrackingContract.toJsonString());
Log.d(TAG, response);
}
});