Reporting Search Term in URL string

Bsmith320

26-09-2016

I need to report search terms that are part of the URL string. The URL "http://about.jstor.org/search/node/jstor" contains the search term, "jstor",  at the end of the URL.

When test "window.location.href.substring(35);" in the developer console, it returns the search term value. When I add s.eVar61 to the string "s.eVar61 = window.location.href.substring(35);" and test it in the console, I get and Uncaught Reference Error. How do I fix it so that I can I parse out and report the search term in the URL string?

 

Thank you,

Bill

Accepted Solutions (1)

Accepted Solutions (1)

Gigazelle

Employee

03-10-2016

if the protocol is absent or different, or if the URL is any longer or shorter, that's going to give you some issues there.

You could try instead using the following:

s.eVar61=window.location.href.split('/search/node/')[1];