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.
$term = $this->terms_lib->search_term;