Skip to content

Unique Personalized Links

A unique personalized link is a campaign specific single-use survey link for a customer that can be generated without talking to our API.

These links are specially usefull if you wish to send personalized links to a large quantity of recipeients and expect a low rate of response and you dont want to record recipients in our platform before an answer is given.

Requirements

There are two fields that are required for generating a unique personalized link:

  • campaign id (an id of an nps.today campaign)
  • secret id (assures that only employees with authroziation access are able to generate the link)

You can find these two ids in the nps.today application. Below are two short guides on how to find them.

Trulli
Fig.1 - Finding campaign id.
Trulli
Fig.2 - Finding secret id.

Optional fields

There are 4 optional fields:

  • Name: the name of the respondent. Typically this field is set to the first and last name of the respondent.
  • Email: the email belonging to the respondent.
  • Phone: the phone number belonging to the respondent.
  • External Id: the id of an external source. This source could be for example be an id of a contact in CRM systems such as Salesforce or Dynamics 365.

Furthermore, you are also allowed to make use of custom fields. If the API does not recognize the field that was given in the URL, it will then be categorized as a custom field. The custom fields will have their values stored on the respondent in a common JSON structure format. The example below demonstrates a URL with custom fields highlighted in red:

https://r.nps.today
?cid=1234
&name=john
&email=john@npstoday
&phone=12345678
&ext=abcd
&sha=ea29dc7c05c4f1506d43622cb9b836189974522f13cea4e56105ccc042eb0333
&car_brand=toyota
&manufacture_date=2004

The easiest and most straight-forward method of generating the link, is by using the nps.today generate url page.

On this page, you are also given the option on specifying a respondent before generating the link. If no name or email is given, the field will get anonymized by the API.

Click on the "generate link" button when you are done filling out the form. Then click on the copy button in order to copy to the clipboard. You are now able to give a customer a personalized survey link!

Trulli
Fig.3 - Generating unique personalized link.

Below are some code examples to get you started if you wish to generate the link using a script:

import hashlib
import uuid
from requests.utils import quote

baseUrl = 'https://r.nps.today'

#fields
cid = '9142'
name = 'John Doe'
email = 'jd@example.com'
phone = '4512345678'
ext = '42'
id = str(uuid.uuid4())

#custom fields
car = 'toyota'
year = '2009'

#hash fields + secret id using SHA 256 algorithm.
secret = '12C48F78F6BQ141EDC9B71C48367251E'
content = cid + name + email + phone + ext + id + secret
sha = str(hashlib.sha256(content.encode('utf-8')).hexdigest())

url = baseUrl + quote(
    "?cid="+cid+
    "&name="+name+
    "&email="+email+
    "&phone="+phone+
    "&ext="+ext+
    "&id="+id+
    "&sha="+sha+
    "&car="+car+
    "&year="+year, safe='~@#$&()*!+=:;,.?/\'')

print("content: " + content)
print("guid: " + id)
print("sha: " + sha)
print("URL: " + url)
const uuidv4 = () => {
    return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g,
        c =>
        (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
    );
}

const digestMessage = async (message) => {
    const msgUint8 = new TextEncoder().encode(message);                           // encode as (utf-8) Uint8Array
    const hashBuffer = await crypto.subtle.digest("SHA-256", msgUint8);           // hash the message
    const hashArray = Array.from(new Uint8Array(hashBuffer));                     // convert buffer to byte array
    const hashHex = hashArray.map(b => b.toString(16).padStart(2, "0")).join(""); // convert bytes to hex string
    return hashHex;
}

(async () => {

const baseUrl = "https://r.nps.today"

//fields
const cid = "9142";
const name = "John Doe";
const email = "jd@example.com";
const phone = "4512345678";
const ext = "42"
const id = uuidv4();

//custom fields
const car = "toyota";
const year = "2009";

//hash fields + secret id using SHA 256 algorithm.
const secret = "12C48F78F6BQ141EDC9B71C48367251E"
const content = cid + name + email + phone + ext + id + secret;
const sha = await digestMessage(content);

const url = encodeURI(baseUrl +
              "?cid=" + cid +
              "&name=" + name +
              "&email=" + email +
              "&phone=" + phone +
              "&ext=" + ext +
              "&id=" + id +
              "&sha=" + sha +
              "&car" + car +
              "&year=" + year);
console.log("content: " + content);
console.log("guid: " + id);
console.log("sha: " + sha);
console.log("URL: " + url);
})();
using System;
using System.Text;
using System.Security.Cryptography;
using System.Web;

public class Program
{
  public static void Main()
  {
    string baseUrl = "https://r.nps.today";

    //fields
    string cid = "9142";
    string name = "John Doe";
    string email = "jd@example.com";
    string phone = "4512345678";
    string ext = "42";
    string id = Guid.NewGuid().ToString();

    //custom fields
    string car = "toyota";
    string year = "2009";

    //hash fields + secret id using SHA 256 algorithm.
    string secret = "12C48F78F6BQ141EDC9B71C48367251E";
    string content = cid + name + email + phone + ext + id + secret;
    string sha = ComputeSha256Hash(content);

    string url = System.Uri.EscapeUriString(baseUrl + "?cid=" + cid + "&name=" + name + "&email=" + email + "&phone=" + phone + "&ext=" + ext + "&id=" + id + "&sha=" + sha + "&car="+car+"&year="+year);
    Console.WriteLine("content: " + content);
    Console.WriteLine("guid: " + id);
    Console.WriteLine("sha: " + sha);
    Console.WriteLine("url: " + url);
  }

  static string ComputeSha256Hash(string rawData)
  {
    using var sha256Hash = SHA256.Create();
    byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(rawData));
    StringBuilder builder = new StringBuilder();
    for (int i = 0; i < bytes.Length; i++)
    {
      builder.Append(bytes[i].ToString("x2"));
    }

    return builder.ToString();
  }
}