Magento WizardNo joke, this website relaunches on 1st April. New look, new features!

Contact the site  Make Money

Echo a Google Search Term on Your Page

 Add to Favourites  
(1 rating, 1 votes)
Loading ... Loading ...

If you have any PPC campaigns through Adwords, you might find echoing the term a user typed in on Google very handy. If someone clicks your ad, you can then show the exact search term they searched for on your page. This can only help to increase conversions and boost sales, as, to the user, they’re seeing exactly what they searched for.

For example, if you search for “Goodmans Wall Brackets” or “Goodmans Wall Mounts“, you’ll see that many companies, including ours, have got adverts either at the top or on the right column for both the above phrases.

Say the user typed it the latter (Goodmans Wall Mounts), and then they clicked your ad, and they arrive at a page advertising Goodmans Wall Brackets, there is a possibility they may get a little confused and leave your page and say goodbye.

Of course, to any normal human being you’d know that mounts and brackets are the same thing – however, why not eliminate any confusion whatsoever… you might as well just echo the term they searched for on Google on your page with a simple bit of PHP! This not only applies to PPC, but if your SEO is right up there, it can also be utilised for organic search results too.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
$referer = strtolower($_SERVER['HTTP_REFERER']);
// see if it comes from google
if (strpos($referer,"google")) {
// delete all before q=
$a = substr($referer, strpos($referer,"q="));
// delete q=
$a = substr($a,2);
// delete all FROM the next & onwards
if (strpos($a,"&")) {
$a = substr($a, 0,strpos($a,"&"));
}
// decode the results
$raw_keywords = urldecode($a);
define('SITETOK', "site:");
if (strpos($raw_keywords,SITETOK) === false) {
$keywords = $raw_keywords;
} else {
$key_arr = explode(' ', $raw_keywords);
$keywords = '';
foreach ($key_arr as $key) {
if (strncmp($key, SITETOK,strlen(SITETOK)) == 0) continue;
$keywords = $keywords . ' ' . $key;
}
}
$key_arr = explode(' ', $keywords);
$search_keywords = '';
$keywords = '';
$unStrictReplace = '[<>]';
foreach ($key_arr as $key) {
if (empty($key)) continue;
$key = ereg_replace($unStrictReplace, '', $key);
if (empty($search_keywords)) {
$search_keywords = $key;
$keywords = $key;
} else {
$search_keywords = $search_keywords . '+' . $key;
$keywords = $keywords . ' ' . $key;
}
}
echo $keywords;
}
?>

Give it a go, just paste in the code above and watch it work on your site…

Google

  • Digg
  • del.icio.us
  • Facebook
  • Google
  • LinkedIn
  • Live
  • Reddit
  • StumbleUpon
  • Technorati
  • TwitThis

about the author

    This article was written by Sam Davis on May 31, 2008.
    Computing over a glass of Grenache Shiraz... again!
    Sam is the Editor of Blasted Thing. Contact Us

related articles

 Send MIME/HTML emails with PHP Mailer
 Using PHP to pull in external data

comments

Leave a Reply




Spam protection by WP Captcha-Free


Using PHP to Pull in External Data

  • Sponsored Ads

  • Magento Themes
    • vtiger: great article, thank you....
  • Recent Tweets

    Magento Developer oDesk: chi flat iron on Looking for russianeast european PHP DEVELOPER oDesk · wholesale jordan ... http://bit.ly/9aWcB8

    Flower Shop Premium Magento E-commerce Theme http://bit.ly/bgve6q

    JM Purity Premium Magento Theme http://bit.ly/aUN2mC

    RAC - Magento Install, Apply Design, Tweaks--By WhiteLabelSEO on Mar 22--Max Bid: $45: 1. Install Magento (or OSCo... http://bit.ly/9KPLk9

    เริ่มสนุกกะ magento commerce