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 6 optional fields:

  • First Name: the first name of the respondent.
  • Last Name: the 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.
  • Employee: the email address of the employee that should be the responsible employee on the campiang member.

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
&firstName=john
&lastName=doe
&email=john@npstoday.com
&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 Unique Personalized Link form on app.nps.today. Navigate to any campaign and click the Unique Personalized Link button (see Fig.3)

Trulli
Fig.3 - Locate Unique Personalized Link form from app.nps.today

From the Unique Personalized Link page, the two required values campaign id and secret is automatically filled. If you want to create a link for another campaign, you can simply change the selected camapign in the first field of the form. Fill any of the optional fields availible and/or one or more custom fields. When ready, click the Generate Link button (see Fig.4)

Trulli
Fig.4 - Locate Unique Personalized Link form

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'
firstName = 'John'
lastName = 'Doe'
email = 'jd@example.com'
phone = '4512345678'
ext = '42'
id = str(uuid.uuid4())
employee = 'employee@company.com'

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

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

url = baseUrl + quote(
    "?cid="+cid+
    "&firstName="+firstName+
    "&lastName="+lastName+
    "&email="+email+
    "&phone="+phone+
    "&ext="+ext+
    "&id="+id+
    "&employee="+employee+
    "&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 firstName = "John";
const lastName = "Doe";
const email = "jd@example.com";
const phone = "4512345678";
const ext = "42"
const id = uuidv4();
const employee = 'employee@company.com'

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

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

const url = encodeURI(baseUrl +
              "?cid=" + cid +
              "&firstName=" + firstName +
              "&lastName=" + lastName +
              "&email=" + email +
              "&phone=" + phone +
              "&ext=" + ext +
              "&id=" + id +
              "&employee=" + employee +
              "&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 firstName = "John";
    string lastName = "Doe";
    string email = "jd@example.com";
    string phone = "4512345678";
    string ext = "42";
    string id = Guid.NewGuid().ToString();
    string employee = 'employee@company.com';

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

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

    string url = System.Uri.EscapeUriString(baseUrl + "?cid=" + cid + "&firstName=" + firstName + "&lastName=" + lastName + "&email=" + email + "&phone=" + phone + "&ext=" + ext + "&id=" + id + "&employee=" + employee + "&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();
  }
}