Do you want to know how your user came to your website via search engine? User usually go to search engine like google and then type a search term and click link from search result page. Â Search term can be used for analytic purpose, or search engine optimization (SEO) method.
First step to catch search term is getting the referrer. If referrer is a search engine, get the  search term, clean it from ‘bad words’ and return the result.  Simple, isn’t it? 🙂
WordPress community have a plugin to do the processes. And then i put some of its code to build library for CodeIgniter. You can download this library here.
Using this library is so simple.
$this->load->library(‘Terms_lib’);
$term = $this->terms_lib->search_term;
Done. 🙂
nice info