News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Sameer Borate's Blog:
Grabbing the referrer search engine keywords for a site
October 18, 2011 @ 13:25:27

On his blog today Sameer Borate has a new post with a handy bit of code you can use to find the keywords from a search engine referral to help with tracking how visitors have come to your site.

A couple of weeks back I had to write a solution for a client to track the referrer search engine from where the user came to his sites contact page, without using Google Analytics. If a user was to fill the contact form on the website, the referring search engine name and the keyword for which it was refereed was to be emailed along with the contact information. The following is a solution for the same.

The code itself is pretty simple - it checks the $_SERVER['HTTP_REFERER'] and, based on an array of search engine types, looks for a certain "query" keyname in the URL and matches what follows (with a regular expression). This can be useful for not only determining what sort of audience is visiting your site, but could also be used to present a custom message to visitors from certain search engines (or, more complicated, to show different content based on search terms).

0 comments voice your opinion now!
search engine keyword referrer url snippet


blog comments powered by Disqus

Similar Posts

David Sklar's Blog: Runkit, "static", and inheritance

Dave Dash's Blog: Finding things using Zend Search Lucene in symfony

PHPClasses.org: Lately in PHP Podcast #43 - "Is Facebook HHVM going to Replace Zend Engine in PHP6"

PHPClasses.org Blog: Locating addresses on Google Maps embedded in PHP generated Web forms

Spindrop.us: Creating, Updating, Deleting documents in a Lucene Index with symfony


Community Events





Don't see your event here?
Let us know!


laravel community release extension series configure interview version introduction conference voicesoftheelephpant unittest symfony list opinion podcast install api composer language

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework