Returns the value of a specified query string parameter, if found in the current page URL or in the provided string.

Because important data (such as campaign tracking codes, internal search keywords, etc.) is available in the query string on a page, getQueryParam helps capture the data into Analytics variables.

This utility replaces the getQueryParam plug-in.


s.Util.getQueryParam(key, [url], [delim])
Note: The syntax for the utility differs from the syntax for the plug-in.


Parameter Description
key (required) The name of the query string parameter that you want to get. This parameter is case sensitive.
url (optional) Default url is s.pageURL or window.location. Specifying a value for this parameter overrides the URL from which the query parameter is retrieved to the one specified.
delim (optional) Parameter delimiter in the URL. Default delimiter is "&". This lets you to specify an alternate query-string delimiter, such as ";".


This function returns the value of the query-string variable or an empty string if it's not found.


s.doPlugins = function(s) {
  s.campaign = s.Util.getQueryParam("cid");