getQueryParam versus Util.getQueryParam

In May 2013, Adobe released an updated data collection library, named AppMeasurement, designed to replace H Code. This new AppMeasurement library contained native support to collect query string parameters, whereas in H Code, additional plug-in code was required.

With the introduction of Util.getQueryParam (included in the AppMeasurement library), there are several key differences to s.getQueryParam (H Code plugin) to consider:

  • Util.getQueryParam is case-sensitive, while s.getQueryParam is not. If Util.getQueryParam is set to look for "cid", it does not recognize the query string parameter "CID" in the URL.
  • Util.getQueryParam does not support the searching of multiple query strings. The s.getQueryParam function could take a comma-delimited string as its first argument.
  • The parameters accepted between plugins are slightly different.
    • s.Util.getQueryParam(key, location, separator)
      • Key (required): The name of the query string. Same as s.getQueryParam.
      • Location (optional): Used if the URL is in a different place than page.URL (e.g. if you want to use it in document.referrer). In s.getQueryParam, location is the third parameter.
      • Separator (optional): If the URL in question uses something other than '&' to separate query strings, an alternate delimiter can be used. This functionality is unique to Util.getQueryParam.
    • s.getQueryParam(key, delimiter, location)
      • Key (required): The name of the query string. Optionally accepts multiple values as a single comma-delimited string.
      • Delimiter (optional): If multiple keys are searched, this value determines how to separate those values.
      • Location (optional): Same functionality as Util.getQueryParam.

Additional resources