Use regular expressions to target specific keywords within visitor search queries on your website and extract valuable insights from complex query strings.
Benefits of targeting complex query strings in URLs using regex:
Combine query strings for a better response
To illustrate, consider the example of Flickr, which supports both simple and complex search URLs for advanced searches. For instance:
Simple Search URL example: https://secure.flickr.com/search/?q=kittens
Regex Configuration for the Example:
This configuration ensures your survey appears whenever visitors search for kittens, puppies, or bunnies.
By using complex query string the following URL:
which offers advanced search functionality, allowing visitors greater control of keywords, image type, date range, and Creative Commons licensing, you can get the following parameters:
Keywords included: tree
Keywords not included: swing
Creative Commons licensing: OK for commercial use
Taken between: 1/1/2017 and 12/31/2026
Content-Type: Photos/Videos
Media Type: Photos & Videos
A lot is going on in these search results. However, parsing back through the options selected makes it easier to pick out search keywords, date parameters, and the other advanced options selected.
Now that you know what the search results path can look like, you can start configuring the target URL with a regular expression.
To target a survey of visitors searching for photos of gardens with Creative Commons commercial licensing, you can use two positive lookaheads to ensure all search parameters are included.
For this, you can add the following characters to regex fields:
Subdomain : secure
TLD : flickr.com
Path : search/?(?=q=gardens).*(?=l=commderiv)
This pattern will match all search pages that have the "q=gardens" keyword (and won't show up if people use a -gardens keyword) and the "l=commderiv" Creative Commons commercial license for the URL:
https://secure.flickr.com/search/?q=gardens&l=commderiv&ct=0&mt=all&adv=1
That is all about using the complex query string in the regular expression. If you encounter any issues or have any questions, feel free to contact our support team.
Related Articles: