GetQueryStringParameter

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

Syntax 

GetQueryStringParameter(1)

Function Properties 

OrdinalTypeDescription
1StringRequired. 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.

1<script runat="server">
2  Platform.Load("Core", "1");
3
4  var custName = Request.GetQueryStringParameter("firstName");
5
6  # Assign a fallback value if the firstName query parameter is not defined or
7  # is an empty string.
8  if (!result) {
9    custName = "friend";
10  }
11</script>
12
13<p>Hello <ctrl:var name="custName" />!</p>

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

1https://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.

1Hello 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.

1Hello friend!