Embed data directly into survey links
High level process
- Enable
Personalised linksfor a channel - Generate signed payload with standard
jwtlibrary using theshared secretfrom previous step - Append the
tokenaspayloadparameter to the survey link
Token format
If the payload will contain a field called id then this will be considered an unique identifier for the response.
For example:
- If set to order id - then with this payload only one response can be created for a single survey and order combincation.
- If set the id to user id - then the user can fill in the survey only once
- in admin interface we always generate unique id - this means that user can answer once with the same link
Code snippet:
import jwt from "jsonwebtoken";
const secret = "SHARED SECRET"; // From sharing channels page
const data = {
id: "123456",
// any additional attributes will become context for the survey
data: "example",
};
// This is server code. Dont put the SHARED SECRET to client side code.
const payload = jwt.sign(data, secret, { expiresIn: "1h" });
// USAGE
// https://youropinion.is/snap/xxx/c/yyy?payload=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
// eyJpZCI6IjEyMzQ1Njc4OTAiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyfQ.
// mIatWmJPRz4-NU7KWcjuOKNnfWUeLPqYhHb-R7FYunE