Skip to content

Instantly share code, notes, and snippets.

@MikeGrace
Created June 11, 2010 05:22
Show Gist options
  • Save MikeGrace/434089 to your computer and use it in GitHub Desktop.
Save MikeGrace/434089 to your computer and use it in GitHub Desktop.
Kynetx app that pulls search term from URL on pageview for Devex question
ruleset a60x267 {
meta {
name "Fire rule on search"
description <<
Fire rule on search
>>
author "Mike Grace"
logging on
}
dispatch {
domain "yahoo.com"
domain "google.com"
domain "bing.com"
}
global { }
rule if_search_term_found is active {
select when pageview "yahoo\.com.*[?&]p=([^&]*)" setting (searchTerm)
or pageview "google\.com.*[?&]q=([^&]*)" setting (searchTerm)
or pageview "bing\.com.*[?&]q=([^&]*)" setting (searchTerm)
pre {
query = page:url("query");
msg = <<
Query string: #{query}<br/>
Search term: #{searchTerm}
>>;
}
if( searchTerm neq "" ) then {
notify("Search Data", msg) with sticky = true;
}
}
rule if_search_term_not_found is active {
select when pageview "yahoo\.com.*[?&]p=([^&]*)" setting (searchTerm)
or pageview "google\.com.*[?&]q=([^&]*)" setting (searchTerm)
or pageview "bing\.com.*[?&]q=([^&]*)" setting (searchTerm)
pre {
query = page:url("query");
msg = <<
Query string: #{query}<br/>
Was a search done?
>>;
}
if( searchTerm eq "" ) then {
notify("Search Data", msg) with sticky = true;
}
}
}
@MikeGrace
Copy link
Author

Updated to properly pull search terms from url on pageview

@MikeGrace
Copy link
Author

Updated with rules that only fire actions if search term is found or not found.
Related Devex question at http://devex.kynetx.com/questions/468/only-fire-rule-if-search-has-been-done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment