How to format URLs when sharing them in emails: if you're using query string parameters, use hyperlinks rather than displaying the URL directly🔗
If you're sending a participant a link to a results program or to a follow-up survey and you want to include customized variables via query string parameters, you have two options:
- You could include the URL in a square-bracketed hyperlink
[like this|https://example.com/path/to/wherever]
in the email. - You could display the URL in the email directly if you encode it first (as in the second example below).
Note: There is a third approach: you could display the URL in the email directly without encoding it first, but this option is not advised. It will cause problems if any of the variables you are including in the query string parameters were strings with spaces!
Example of how to send customized URLs as hyperlinks🔗
*question: What would you like to see displayed in your results program?
*save: answer
>> urlForHyperlink = "https://www.guidedtrack.com/programs/t5p3108/run?theirAnswer={answer}"
*email
*subject: Your results
*to: {theirAddress}
*body
Click [here|{urlForHyperlink}] for your results.
In this example, if you use {theirAnswer}
in the results program, the participant will see the answer they typed, including any spaces it contained.
Example of how to encode then send customized URLs for people to paste into their browser🔗
*question: What would you like to see displayed in your results program?
*save: answer
>> urlToEncode = "https://www.guidedtrack.com/programs/t5p3108/run?theirAnswer={answer}"
>> encodedURL = urlToEncode.encode("URL")
*email
*subject: Your results
*to: {theirAddress}
*body
Click [here|https://www.guidedtrack.com/programs/fq40wv0/run?theirAnswer={answer}] for your results.
Or paste this into your browser: {encodedURL}
In the results program, in order for the encoded URL to display properly, you would need to then include the following:
>> decoded = theirAnswer.decode("URL")
And after that, you can display the variable using the standard syntax:
{decoded}
If you didn't decode the variable, it wouldn't display correctly. For example, if the participant entered an answer such as the one shown below, then the results program accessed from the link in this example will display that answer variable incorrectly unless it is decoded before being displayed.
In the results program linked to in the email example above, here are examples of the way the above variable would be displayed depending on whether or not it is decoded before being placed in the {curly brackets}:
Bad example of sending a URL for participants to copy without encoding it first🔗
*question: What would you like to see displayed in your results program?
*save: answer
*email
*subject: Test
*to: {theirAddress}
*body
Click [here|https://www.guidedtrack.com/programs/fq40wv0/run?theirAnswer={answer}] for your results.
Or click here: https://www.guidedtrack.com/programs/fq40wv0/run?theirAnswer={answer}
In this example, if your participant enters text with spaces as the answer to one of the variables that you're saving using query string parameters, then in the email it will appear that the URL finishes after the first space.
Next: How to use the `*randomize`, `*group`, and `*experiment` keywords judiciously