Net Promoter Score Aggregator

Get NPS stats for different time frames

The Net Promoter Score helps to segment and understand your customer's sentiments towards your product by grouping them into three categories:

  • Promoters:These are customers who are happy with your product and likely to recommend it to others.
  • Passives:These are customers who use your product because it meets their needs and might not go out of their way to recommend it to others.
  • Detractors:These are customers for whom your product does not satisfy their complete needs and are likely to churn over time.

Each segment is weighed on a scale between 0 to 10. With detractors rated between 0 to 6, Passives between 7 and 8, and Promoters 9 to 10.

The final NPS score is calculated as follows: NPS = (number of promoters / total number of reviews with NPS * 100) − (number of detractors / total number of reviews with NPS * 100) This value can be found in the response as rating.

The response is also grouped into periods of 7 days, 30 days, and 365 days, as well as your overall rating to date.

You can fetch the NPS score for specific channels by specifying the channel id in the request body. The results for all channels are returned if the request body is set to an empty object {}

Request Body example:

{
    "channels": [
   {"id":"chl-abc"},
   {"id":"chl-xyz"}
   ]
    "touchpoints": [
   {"id":"checkout"},
   {"id":"$$empty"}
   ]
}

NB: In other to start collecting NPS surveys you will have to select the NPS template in the control center. Reach out to your CSM in case it's not yet available in your control center. NB: as Event-Types/touchpoints may be empty (e.g.), a fallback/default touchpoint, "$$empty" exists, which may be used to specifically address reviews without eventtype/touchpoint

Parameters

HTTP Headers

Name Description
Authorization

An OAuth token in the form "Bearer {accessToken}"

Body

Content-Type Type
application/json ReviewRequestDto
{ "channels": [ { "id": "value goes here" } ], "touchpoints": [ { "id": "value goes here" } ] }

Responses

200 - The stats was fetched successfully.

Name Description
application/json ReviewResponseDto
{ "7days": { "rating": "value goes here", "count": "value goes here", "distribution": { "promoters": "value goes here", "passives": "value goes here", "detractors": "value goes here" } }, "30days": { "rating": "value goes here", "count": "value goes here", "distribution": { "promoters": "value goes here", "passives": "value goes here", "detractors": "value goes here" } }, "90days": { "rating": "value goes here", "count": "value goes here", "distribution": { "promoters": "value goes here", "passives": "value goes here", "detractors": "value goes here" } }, "365days": { "rating": "value goes here", "count": "value goes here", "distribution": { "promoters": "value goes here", "passives": "value goes here", "detractors": "value goes here" } } }

400 - Bad Request

No body is sent for this status code.

401 - Unauthorized

No body is sent for this status code.

403 - Forbidden

No body is sent for this status code.

404 - Not Found

No body is sent for this status code.
POST
https://api.etrusted.com/aggregations/nps
/** * Please be aware that storing your Authorization on the client side is strongly discourge. * This code example should only be used for testing purposes. */ //#region Parameters const baseUrl = 'https://api.etrusted.com'; const headers = { 'Authorization': null, // Change me! }; const body = { "channels": [ { "id": "value goes here" } ], "touchpoints": [ { "id": "value goes here" } ] }; //#endregion let url = `${baseUrl}/aggregations/nps`; const xhr = new XMLHttpRequest(); xhr.open('POST', url, true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('Authorization', `${headers["Authorization"]}`); xhr.onreadystatechange = function() { if(xhr.readyState == 4 && xhr.status == 200) { console.log(xhr.responseText); } }; xhr.send(body || undefined);
const https = require('https'); //#region Parameters const baseUrl = 'https://api.etrusted.com'; const headers = { 'Authorization': null, // Change me! }; const body = { "channels": [ { "id": "value goes here" } ], "touchpoints": [ { "id": "value goes here" } ] }; //#endregion let urlAsString = `${baseUrl}/aggregations/nps`; const queryString = Object .keys(queryParameters) .map(key => `${key}=${encodeURIComponent(queryParameters[key])}`) .join('&'); urlAsString = queryString ? `${urlAsString}?${queryString}` : urlAsString; const url = new URL(urlAsString); const options = { hostname: url.hostname, port: url.port, path: url.path, method: 'POST', headers: { 'Authorization': `${headers["Authorization"]}`, 'Content-Type': 'application/json' } }; const req = https.request(options, res => { console.log(`statusCode: ${res.statusCode}`) res.on('data', d => { process.stdout.write(d) }); }); req.on('error', error => { console.error(error) }); if (body) { req.write(JSON.stringify(data)); } req.end();
require "uri" require "json" require "net/http" baseUrl = "https://api.etrusted.com"; # Some query parameters are optional and should only be set if needed. queryStringParameters = { } routeParameters = { } headers = { "Authorization": nil, # Change me! } queryStringValues = queryStringParameters.to_a queryStringPairs = queryStringValues.map { |entry| entry[0].to_s + "=" + (entry[1] || '') }; queryString = queryStringPairs.join('&') urlAsString = baseUrl + "/aggregations/nps" + (queryString != "" ? "?" + queryString : "") urlAsString.gsub!(/\{[^\}]*\}/) { |m| routeParameters[m[1...-1].to_sym] } if urlAsString url = URI(urlAsString) https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = headers["Authorization"] request["Content-Type"] = "application/json" request.body = JSON.dump({ "channels": [ { "id": "value goes here" } ], "touchpoints": [ { "id": "value goes here" } ] }) response = https.request(request) puts response.read_body
//#region Imports import java.net.URL; import java.net.URLEncoder; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.lang.StringBuffer; import java.util.Map; import java.util.HashMap; import java.util.AbstractMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.ArrayList; //#endregion public class main { public static final Pattern PATTERN = Pattern.compile("\\{([^\\}]*)\\}"); public static void main(String[] args) throws IOException { try { Map<String, String> headers = new HashMap<>(); Map<String, String> queryStringValues = new HashMap<>(); Map<String, String> routeParameters = new HashMap<>(); //#region Parameters String body = new StringBuilder() .append("{") .append(" \"channels\": [") .append(" {") .append(" \"id\": \"value goes here\"") .append(" }") .append(" ],") .append(" \"touchpoints\": [") .append(" {") .append(" \"id\": \"value goes here\"") .append(" }") .append(" ]") .append("}") .toString(); String baseUrl = "https://api.etrusted.com"; headers.put("Authorization", null); // Change me! //#endregion String urlAsString = baseUrl + "/aggregations/nps"; Matcher matcher = PATTERN.matcher(urlAsString); StringBuffer out = new StringBuffer(); while (matcher.find()) { String variable = routeParameters.get(matcher.group(1)); matcher.appendReplacement(out, variable); } matcher.appendTail(out); urlAsString = out.toString(); ArrayList<String> queryStringParts = new ArrayList<>(); for (String key : queryStringValues.keySet()){ queryStringParts.add(key + "=" + URLEncoder.encode(queryStringValues.get(key))); } if (queryStringParts.size() > 0) { urlAsString += "?" + String.join("&", queryStringParts); } URL url = new URL(urlAsString); HttpURLConnection httpRequest = (HttpURLConnection) url.openConnection(); for (String key : headers.keySet()){ httpRequest.setRequestProperty(key, headers.get(key)); } httpRequest.setRequestMethod("POST"); httpRequest.setRequestProperty("Content-Type", "application/json"); httpRequest.setDoOutput(true); OutputStream outputStream = httpRequest.getOutputStream(); OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream, "UTF-8"); outputStreamWriter.write(body); outputStreamWriter.flush(); outputStreamWriter.close(); outputStream.close(); httpRequest.connect(); BufferedReader in = new BufferedReader(new InputStreamReader(httpRequest.getInputStream())); String inputLine; StringBuffer content = new StringBuffer(); while ((inputLine = in.readLine()) != null) { content.append(inputLine); } in.close(); int status = httpRequest.getResponseCode(); httpRequest.disconnect(); System.out.println("Response Status: " + String.valueOf(status)); System.out.println("Response Body: " + content.toString()); } catch (MalformedURLException ex) { System.out.println("URL provided not valid"); } catch (IOException ex) { System.out.println("Error reading HTTP connection" + ex.toString()); throw ex; } } }
<?php //#region Parameters $baseUrl = 'https://api.etrusted.com'; $headers = array( "Authorization" => null, // Change me! ); // Change me! $body = json_decode('{ "channels": [ { "id": "value goes here" } ], "touchpoints": [ { "id": "value goes here" } ] }'); //#endregion $url = "$baseUrl/aggregations/nps"; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => json_encode($body), CURLOPT_HTTPHEADER => array( "Content-Type: application/json", "Authorization: " . $headers["Authorization"], ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
import http.client import json from urllib.parse import urlparse # Some query parameters are optional and should only be set if needed. query_string_parameters = { } route_parameters = { } headers = { 'Content-Type': 'application/json' 'Authorization': '', # Change me! } url_as_string = 'https://api.etrusted.com/aggregations/nps'.format(**{ **query_string_parameters, **route_parameters }) payload = '' payload = json.dumps({ "channels": [ { "id": "value goes here" } ], "touchpoints": [ { "id": "value goes here" } ] }) url = urlparse(url_as_string) http_client = http.client.HTTPSConnection(url.netloc) http_client.request("POST", url_as_string, payload, headers) response = http_client.getresponse() data = response.read() print(data.decode("utf-8"))
curl 'https://api.etrusted.com/aggregations/nps' \ --request POST \ --data-raw '{ "channels": [ { "id": "value goes here" } ], "touchpoints": [ { "id": "value goes here" } ] }' \ --header 'Content-Type: application/json' \ --header 'Authorization: value' \ --location
This feature is coming soon!
The operation tester will give you the possibility to pre-test operations with our sandbox environment.
What would you expect from the operation tester? Tell us your opinion!

Models

ReviewRequestDto

Properties

channels
object[]

touchpoints
object[]

ReviewResponseDto

The stats was fetched successfully.

Properties

7days
object

Properties
rating
integer

count
integer

distribution
object

Properties
promoters
integer

passives
integer

detractors
integer

30days
object

Properties
rating
integer

count
integer

distribution
object

Properties
promoters
integer

passives
integer

detractors
integer

90days
object

Properties
rating
integer

count
integer

distribution
object

Properties
promoters
integer

passives
integer

detractors
integer

365days
object

Properties
rating
integer

count
integer

distribution
object

Properties
promoters
integer

passives
integer

detractors
integer

Need further support?

Visit the Help Centre for further information, or contact us. Are some words or terms unfamiliar? Then visit the glossary for clarification.