Skip to main content
Level 3
Oct 16, 2015 2:30 AM UTC
Solved

How do I parse a URL to capture internal search term terms?

I need to parse the search results page URL to report on the search term. Example: http://about.jstor.org/search/site/plants - "plants" is the search term

I am not sure how the custom JS should to be set-up. Do I use "var url=window.location.href"? Is the JS set-up to capture the term after /search/site/?

How I am not sure how to do this and would appreciate some help. 

Thank you,

Bill

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Kaushalendra
KaushalendraAccepted solution
Adobe Employee
Oct 16, 2015 2:30 AM UTC

Hi Bill,

You can use a script something like below:

var url = "http://about.jstor.org/search/site/plants"; var v; if (url.indexOf('search/site') > 0){ v = url.substr(url.indexOf('search/site')+12); }

The value we are capturing here in variable 'v' can also be populated to a custom variable.

Regards,
Kaushalendra Singh

2 replies

Bsmith320Author
Level 3
Oct 16, 2015 2:30 AM UTC

Thank you. I will give the code a try.

 

 

Bill

Translate
Kaushalendra
Adobe Employee
KaushalendraAdobe EmployeeAccepted solution
Adobe Employee
Oct 16, 2015 2:30 AM UTC

Hi Bill,

You can use a script something like below:

var url = "http://about.jstor.org/search/site/plants"; var v; if (url.indexOf('search/site') > 0){ v = url.substr(url.indexOf('search/site')+12); }

The value we are capturing here in variable 'v' can also be populated to a custom variable.

Regards,
Kaushalendra Singh

Translate