This document contains conceptual, procedural, and scenario information about HTTP AMPscript functions.

Why Use the HTTP AMPscript Functions

You can use these functions to include and manipulate web content within email messages and landing pages.

How To Use the HTTP AMPscript Functions

Create your AMPscript using the functions below and place them in the content areas of landing pages and email messages. For example, you can use the URLEncode() function to encode spaces or non-alphanumeric characters contained in a URL for use by your subscribers.


Returns the content from a specified URL. This function only works with HTTP on port 80 and HTTPS on port 443. Non-standard port assignments cause this function to fail. ExactTarget honors any character set returned in the HTTP headers via Content-Type. For example, you can use a UTF-8 encoded HTML file with Content-Type: text/html; charset=utf-8 included in the header. If the encoding is not specified in the header, the application assumes all returned data will be in the character set WindowsCodePage 1252. You can change this default by contacting Global Support.


  • S1    The URL from which to return content
  • B1    (Optional) Defines whether the process continues on error. Defaults to false. A value of true ignores errors in process.
  • N1   (Optional) Defines whether the function allows empty content. This function defaults to 0.
    • A value of 0 allows for empty content
    • A value of 1 returns an error
    • A value of 2 skips the subscriber. 
  • S2   (Optional) Output of function status.
    • A value of 0 indicates status is OK
    • A value of -1 indicates a missing URL
    • A value of -2 indicates an HTTP request error
    • A value of -3 indicates empty content; the function completed successfully, but no content was returned



System returns the content of


System returns the content of The function stops if it encounters an error, and it allows empty content. The status of the function is returned to the declared variable @CallStatus.


Retrieves the specified header from an HTTP request. Use only in landing pages.


  • S1    The header to be retrieved from an HTTP request



System returns value of the Referer header from the HTTP request.


Indicates if the passed-in user agent value represents a CHTML browser. CHTML browsers (such as those found on feature phones) use a modified version of HTML to display information on smaller screens with less resources than smartphones). This function returns a value of true or false indicating whether the browser uses CHTML. You can use this value to determine whether or not to display CHTML content.


  • S1   The brower user-agent value


REPLACE IsCHTMLBrowser("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36")

System returns false because the provided user-agent value represents a Chrome browser on Windows.

IsCHTMLBrowser("DoCoMo/2.0 MST_v_SH2101V(c100)")

System returns true because the provided user-agent value represents a known CHTML browser on a feature phone.


This example uses the HTTPRequestHeader AMPscript funciton to return the browser user-agent value from the current browser. System returns the appropriate value for the provided user-agent value.


Allows a client to specify the target of a link be a complete URL stored in an attribute, DE (data extension) field, or variable. This function may be used only in HTML emails within the href attribute of an <A> tag. In text emails, it must be prefixed with"http://" and there can be 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 the AMPscript.


  • S1    Function or substitution string to which to redirect


Given the data extension Vacation_Deals:

Customer_ID     Type         Link
123                    Flight
123                    Car  
456                    Hotel

Var @rows, @link, @cntr, @type
Set @rows=LookupRows("Vacation_Deals","CustomerID","123")
For @cntr=1 to Rowcount(@rows) do
        set @type=Field(Row(@rows, @cntr),"type")
        set @link=Field(Row(@rows, @cntr),"link")
<a href="%%=RedirectTo(@link)=%%">%%=v(@type)=%%</a>

Next @cntr

System returns:

Flight Deals

Car Deals

Where Flight Deals links to and Car Deals links to

You can also use this function to include data extension values at the end of a hyperlink within an email message, as shown in the example below:

%%[Set @email = '' 
Set @firstName = 'Angel' 
Set @url = Concat('',@email,'&name=',@firstName)]%% 

<a href = "%%=RedirectTo(@url)=%%">Click Here</a>

System returns:


Returns the specified URL with spaces replaced with %20 or fully encodes all non-alphanumeric characters.


  • S1    String containing the URL and attribute value
  • B1    (optional) Boolean value indicating how the function handles illegal URL characters. If you do not specify this value or set the value to 0, the function replaces spaces in the URL with %20. If you set this value to 1, the function encodes any character illegal for use in a URL (such as spaces and accented letters) in the query string of the given URL.
  • B2    (optional) Boolean value indicating how the function encodes passed string values. If you do not specify this value or set the value to 0, the function encodes only the portion of the passed string following the ? character. If you set this value to 1, the function encodes the full passed string.


URLEncode(" name")

System returns:


Returns a wrapped URL for the long URL provided in the string parameter of the function. Only URLs longer than 975 characters can be modified, and this function does not replace the standard link wrapping functionality implemented in the ExactTarget application. It is intended to mitigate a known limitation with long URLs in Microsoft Outlook 2007 and applies to URLs such as those included in an image source tag.


  • S1    The long URL to be wrapped


In the case where an image source URL exceeds 975 characters, use the function as shown below:


This function returns a wrapped URL that can be used in your send to ensure compatibility with Outlook 2007. If this function is used on a URL with less than 975 characters, the URL will pass unchanged and the call will not break the send. Links wrapped with WrapLongURL remain incompatible with Always On Clicks. If your Member DB is down, a WrapLongURL will not work.

Was This Page Helpful?
Last updated by ryan.williams at 11:23, 27 Jun 2014