amitiitr11 / analytics-api-samples

Automatically exported from code.google.com/p/analytics-api-samples
0 stars 0 forks source link

_ga.extractParamFromUri_ not working correctly #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Change/update the _ga.extractParamFromUri_
2.
3.

What is the expected output? What do you see instead?
The expected output is a clean uri. The output currently is: undefined

What version of the product are you using? On what operating system?
v5, Google Chrome, Mozilla Firefox, Safari and IE.

Please provide any additional information below.

In order to get the function working and return the uri: the function needs to 
be replaced with:
/**
 * Extracts a query parameter value from a URI.
 * @param {string} uri The URI from which to extract the parameter.
 * @param {string} paramName The name of the query paramater to extract.
 * @return {string} The un-encoded value of the query paramater. underfined
 *     if there is no URI parameter.
 * @private
 */
_ga.extractParamFromUri_ = function(uri, paramName) {
  if (!uri) {
    return;
  }
  var uri = uri.split('#')[1];  // Remove anchor.
  var parts = uri.split('?');  // Check for query params.
  if (parts.length != 1) {
    return;
  }
  var query = decodeURI(parts[0]);
  // Find url param.
  paramName += '=';
  var params = query.split('&');
  for (var i = 0, param; param = params[i]; ++i) {
    if (param.indexOf(paramName) === 0) {

      return unescape(param.split('=')[1]);
    }
  }

  return;
};

Original issue reported on code.google.com by kay.heu...@gmail.com on 6 Oct 2011 at 7:12

GoogleCodeExporter commented 9 years ago
Have you this

Original comment by chamdao1...@gmail.com on 27 Nov 2013 at 2:36

GoogleCodeExporter commented 9 years ago

Original comment by chamdao1...@gmail.com on 27 Nov 2013 at 2:41

Attachments: