HTTPRequestHeader

This function returns a specified header from an HTTP request. This function is only available in landing pages, microsites and CloudPages. It cannot be used in other Marketing Cloud applications.

Argument

HTTPRequestHeader(1)

Ordinal Type Required Description
1 String True An HTTP header as defined in RFC 7231

NOTE: Only headers that are available in the page request return a value. For example, if a user pastes a URL into a web browser instead of clicking on a page hyperlink (from another web page), the Referer header value will be empty.

Example

The following example retrieves HTTP headers from a web page session.

%%[

var @referrer, @userAgent, @host
set @referrer = HTTPRequestHeader("Referer")
set @userAgent = HTTPRequestHeader("User-Agent")
set @host = HTTPRequestHeader("Host")

]%%
Referrer is %%=v(@referrer)=%%
<br><br>User Agent is %%=v(@userAgent)=%%
<br><br>Host is %%=v(@host)=%%

Output

The request will return HTML content from the source URL.

Referrer is https://mystore.com/offers/?pageid=123

User Agent is Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36

Host is pub.s1.exacttarget.com