It is also possible to use a regular expression to target specific keywords that come up when your visitors search on your own website.
Your implementation will depend on how your search results URLs are formatted.
Most of them include a question mark before the search terms, but depending on the search parameters are implemented, there can be a lot of parts to the search path that have be be pulled apart before they can be targeted.
Simple Search URL
Flickr is a great example of having a simple search URL and a complex one for advanced searches. Their regular search results URLs are formatted like this:
https://secure.flickr.com/search/?q=kittens
The search page is on /search/ and the keywords themselves occur after a "?q=
" pattern. If you wanted to show a survey on search pages for kittens, puppies and bunnies, you could use an "or" pipe to target just those keywords.
To use this example, you would add the following to your regex fields: Subdomain : TLD : Path : |
Your survey would show up anytime a visitor searched for "kittens," "puppies" or "bunnies."
Complex Search URL
Flickr also offers advanced search functionality, which allows visitors greater control of keywords, image type, date range, and Creative Commons licensing. Here's the results when I search for the following parameters in Advanced Search:
Keywords including: tree
Keywords not including: swing
Creative Commons licensing: OK for commercial use
Taken between: 1/1/2000 and 12/31/2005
Content Type: Photos/Videos
Media Type: Photos & Videos
https://secure.flickr.com/search/?q=tree+-swing&l=commderiv&
d=taken-20000101-20051231&ct=0&mt=all&adv=1
There's a lot going on in these search results. However, parsing back through the options selected, it gets a little easier to pick out search keywords, date parameters, and the other advanced options selected.
Now that we know what the search results path can look like, we can start configuring the target URL with a regular expression. For example, if we want to target a survey at visitors who are searching for photos of gardens with Creative Commons commercial licensing, we can use two positive lookaheads to make sure all search parameters are included.
To use this example, you would add the following to your regex fields: Subdomain : TLD : Path : |
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.
https://secure.flickr.com/search/?q=gardens&l=commderiv&ct=0&mt=all&adv=1
Notes:
- The rest of the search URL can be anything - other search keywords as well, different file types, additional date ranges - but if those two terms are not present, then the survey will not show up.
- Don't forget to add the "
.*
" before the second positive lookahead, or it will assume that the search URL contains both terms exactly next to each other ("q=gardensl=commderiv
") which is not how it is formatted. - If the "
q=gardens
" was somewhere in the middle of the string, then you would want to add a ".*
" before it as well.
Comments
0 comments
Article is closed for comments.