RedirectTo Function

The RedirectTo function allows you to use a URL that is stored as a variable or in a data extension.

Use case: the RedirectTo function can be used to dynamically populate a URL based on values in a data extension.

For example, if I wanted to have a unique subscriber-level URL based on data attributes, I can pull those data attributes from a DE and concatenate it in a URL string using the Concat function.

Syntax:



RedirectTo(1)
1 = URL string or variable to use as a link in content

Example:


 %%[
set @URL1 = “http://ampscript.com/”
set @URL2 = “ampscript-functions/”
set @URL = Concat(@URL1, @URL2)
]%%
Click < a href="%%=RedirectTo(@URL)=%%" > here< /a >

Output:

Click here (with "here" linked to https://ampscript.com/ampscript-functions/)

Explanation:

In the RedirectTo example above, the two strings in the variables @URL1 and @URL2 are concatenated to form the URL string of https://ampscript.com/ampscript-functions/.

Then we simply use an a href= HTML tag to link the “here” text in “click here.”

Related functions is the Concat function.

Leave a Reply

Your email address will not be published. Required fields are marked *