Expand my Community achievements bar.

SOLVED

Reporting Search Term in URL string

Avatar

Level 4

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

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

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];

View solution in original post

2 Replies

Avatar

Correct answer by
Employee Advisor

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];

Avatar

Level 4

I will give it a try.

Thank you