Show Menu
TOPICS×

Util.getQueryParam

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.
Syntax:
s.Util.getQueryParam(key, [url], [delim])

The syntax for the utility differs from the syntax for the plug-in.
Parameters:
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 ";".
Returns:
The function will return an empty string "" if no key is supplied, or if none of the URL options exists, or if the key is not found in the URL. If a fragment delimiter # is found in the URL, everything following the fragment delimiter is not considered. If the key exists and is assigned to a value, the value is URL decoded and returned.
Example:
s.doPlugins = function(s) { 
  s.campaign = s.Util.getQueryParam("cid"); 
};