RedirectTo()

Creates a link using data from an attribute, data extension field, or variable.

Only use this function in HTML emails within the href attribute of an <a> tag. In text emails, include the prefix http:// and ensure that there are no spaces within the parentheses.

In order to retain tracking information for clicked links, you must include the anchor tags <a></a> within the email itself and not the link retrieved via AMPscript. This function only provides tracking information for clickable links within an email message. You can’t retrieve tracking information when using this function with URLs stored in a variable or used as part of a query string parameter.

The RedirectTo() function has one parameter:

  • targetUrl (string): Required. The URL string to redirect to.

To use this function, pass it a URL to redirect to.

This example uses a data extension called Vacation_Deals that contains the data in this table.

Customer_IDTypeLink
123Flighthttp://example.com/flights/
123Carhttp://example.com/cars/
456Hotelhttp://example.com/hotels/

The function returns two links:

The "Flight Deals" link points to http://example.com/flights/, and the "Car Deals" link points to http://example.com/cars/.

This example shows how you can also use this function to include data extension values at the end of a hyperlink within an email message.

The function returns a link that resembles this example.