GetQueryStringParameter

Retrieves the value of a query string parameter from the URL of a landing page or CloudPages page.

Syntax

GetQueryStringParameter(1)

Function Properties

Ordinal Type Description
1 String Required. The key name of a query string parameter in the URL of a landing page or CloudPages page.

Example

This code example retrieves the value of the firstName query string parameter in the URL.

<script runat="server">
  Platform.Load("Core", "1");

  var custName = Request.GetQueryStringParameter("firstName");

  # Assign a fallback value if the firstName query parameter is not defined or
  # is an empty string.
  if (!result) {
    custName = "friend";
  }
</script>

<p>Hello <ctrl:var name="custName" />!</p>

For example, assume that a user visits a page with this URL:

https://www.example.com/welcome.htm?firstName=Martina

In this case, because the firstName query parameter has a value, the user sees a message that includes their name.

Hello Martina!

However, if the firstName query parameter wasn’t present in the URL, or if the key was specified without a value, the user sees a generic message that contains a fallback value for the custName variable.

Hello friend!