9, July 2008

Ads Triggered by Keywords Used to Get To My Site From Search Engines - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Ads Triggered by Keywords Used to Get To My Site From Search Engines
« previous next »
Pages: [1] 2 Print

Author Topic: Ads Triggered by Keywords Used to Get To My Site From Search Engines  (Read 988 times)
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« on: Feb 17, 2007, 12:36:14 PM »

i wish to show relevant ads based on keywords used by my visitors to get to my site via the search engines. certain keywords will trigger the display of ads. this is what i got so far...

Code:
<?php
$ref 
getenv("HTTP_REFERER");
list (
$server$arguments) =  explode("q="$ref);
list (
$keywords$garbage) = explode("&"$arguments);
$pattern "\+";
$replacement " ";
$keywords_spaces ereg_replace($pattern$replacement$keywords);
?>


is this correct? i hope you guys can help me finish it. thanks!


Last blog : Alona Beach, Bohol, Philippines
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6274
38470 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Feb 17, 2007, 01:29:25 PM »

I remember that Nick posted a regex pattern to parse a google url, check the php forum at webdigity


Last blog : 4th of July Lottery from TemplateMonster.com
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7945
40623 credits
Members referred : 3



« Reply #2 on: Feb 17, 2007, 01:47:32 PM »


Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #3 on: Feb 17, 2007, 04:17:04 PM »

great! what if i wish to accomodate all search engines? and how can i trigger the ads when certain keywords come up? i know i can figure this one out for myself if you guys can just point me to some examples. thanks again.


Last blog : Alona Beach, Bohol, Philippines
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7945
40623 credits
Members referred : 3



« Reply #4 on: Feb 18, 2007, 02:55:05 AM »

It would be very difficult to do this for every search engine , and as in most sites the 80%+ of the search engine traffic is from google I guess it is not really important to implement it.

When you are talking about ads, do you mean adsense or something else?

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #5 on: Feb 18, 2007, 08:31:50 AM »

i will popunder affiliate merchant's page.

is this correct?

Code:
<?php
$ref 
parse_url($_SERVER['HTTP_REFERER']);

if ( 
strstr($ref['host'], 'google') )
{
$qStr urldecode(array_shift(explode('&'array_pop(explode('q='$ref['query'])))));
echo $qStr;

 // load adwords1 list
$adwords1 = @file("adwords1.txt");

// open popunder page 1 if keyword is found in adwords1 file
if (!in_array($qStr$adwords1)) {
                
// SO HOW DO YOU OPEN POPUNDER HERE?

// load adwords2 list
$adwords2 = @file("adwords2.txt");

// open popunder page 2 if keyword is found in adwords2 file
if (!in_array($qStr$adwords2)) {
                
// SO HOW DO YOU OPEN POPUNDER HERE?
}

?>



Last blog : Alona Beach, Bohol, Philippines
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #6 on: Feb 19, 2007, 04:23:52 PM »

hey Nik,

im almost finished with the script im working on. theres just this one itty bitty part that is lacking.

Code:
 
<?php
// if for example i already obtained the keywords my surfer used to enter my site...

$keyword "a bottle of tomato catsup";

// and i want to keep an eye out for catsup in the keywords so i will know when to display a catsup ad, how should i do it in the if/else conditional statement?

if  (array($keyword) == "catsup") {  // do you have a tutorial for this part here? this is where im facing a blank wall right now
// open an advertisement
} else {
// do nothing 
}
?>


i hope you will help me. thanks!
« Last Edit: Feb 19, 2007, 04:29:36 PM by vbignacio »


Last blog : Alona Beach, Bohol, Philippines
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7945
40623 credits
Members referred : 3



« Reply #7 on: Feb 19, 2007, 04:28:57 PM »


Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #8 on: Feb 19, 2007, 04:34:10 PM »

thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you


Last blog : Alona Beach, Bohol, Philippines
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7945
40623 credits
Members referred : 3



« Reply #9 on: Feb 19, 2007, 04:35:04 PM »

(You are welcome)^8 Tongue

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #10 on: Feb 19, 2007, 07:30:14 PM »

Nik, heres the code. did i do it right? i just pieced together codes from different sources.

Code:
<?php

$url 
eregi_replace("http(s){0,1}(://)(www.){0,1}"""$_SERVER["HTTP_REFERER"]);

// list of all SE's you want to search ( name => regex )
$SE = array("google" => "\.*google\.",
"alltheweb" => "alltheweb",
"msn" => "search\.msn",
"freeserver" => "search\.freeserve",
"altavista" => "altavista\.com",
"askjeeves" => "ask\.",
"hotbot" => "hotbot",
"lycos" => "search\.lycos",
"netscape" => "search\.netscape",
"aolsearch" => "aolsearch\.aol",
"yahoo" => "\.*yahoo\.",
"looksmart" => "looksmart\.com",
"dmoz" => "search\.dmoz",
"dogpile" => "dogpile\.com");

// finds keywords in url using either query, q, or p as the variable
preg_match("'(query|q|p)=(.*?)(&| )'si"" $url "$keywords);

// find the SE that was used
foreach($SE as $name => $regex) {
if (eregi($regex$url)) {
$se $name;
break;
}
}

if ((
$keywords[1] != "") and ($keywords[1] != " ")) {
$search = array("/\+/""/%2B/i""/%2E/i""%22""%20");
$replace = array(" "" ""\.""\""" ");
$keyword preg_replace($search$replace$keywords[1]);
                $keyword_array explode(' '$keyword);

if (
in_array("catsup"$keyword_array)) {
    echo "catsup found";
   }
else {
echo "none found";
   }
}

?>

« Last Edit: Feb 20, 2007, 01:28:51 PM by vbignacio »


Last blog : Alona Beach, Bohol, Philippines
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #11 on: Feb 20, 2007, 03:59:40 AM »

Nik,

since i have to place the harvested keywords inside the array like this:

Code:
<?php
    $keyword 
"mayonaise, catsup, mustard";
    
$keyword_array = array($keyword);

if (
in_array("catsup"$keyword_array)) {
    echo 
"catsup found";
?>


it doesnt work. but if i do it like in your example, it works. now why is that so? how will i place the harvested keywords?

sorry for the many questions Nik, i dont know any programmer... thanks!


Last blog : Alona Beach, Bohol, Philippines
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6274
38470 credits
Members referred : 374


It's time to use PHP5!


« Reply #12 on: Feb 20, 2007, 08:30:09 AM »

you should always check the manual for the right syntax:
Code:
<?php
$keyword_array 
= array("mayonaise""catsup""mustard");

if (
in_array("catsup"$keyword_array)) {
    echo 
"catsup found";
?>


Last blog : 4th of July Lottery from TemplateMonster.com
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #13 on: Feb 20, 2007, 08:52:29 AM »

thank you sir! olaf sir!


Last blog : Alona Beach, Bohol, Philippines
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6274
38470 credits
Members referred : 374


It's time to use PHP5!


« Reply #14 on: Feb 20, 2007, 09:04:57 AM »

thank you sir! olaf sir!

you're welcome Wink


Last blog : 4th of July Lottery from TemplateMonster.com
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #15 on: Feb 20, 2007, 09:14:48 AM »

one more thing byron, is it possible to dynamically insert values inside an array? from this variable taken from the search engines --> $keyword

$keyword_array = array(<--into this part here-->);


Last blog : Alona Beach, Bohol, Philippines
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6274
38470 credits
Members referred : 374


It's time to use PHP5!


« Reply #16 on: Feb 20, 2007, 09:19:40 AM »

one more thing byron, is it possible to dynamically insert values inside an array? from this variable taken from the search engines --> $keyword

$keyword_array = array(<--into this part here-->);


single:
$keyword_array[] = "value";

multiple:
http://www.php.net/array_push Visit through proxy


Last blog : 4th of July Lottery from TemplateMonster.com
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #17 on: Feb 20, 2007, 09:32:31 AM »

so thats what its called. i was up all night trying to figure it out. thanks again!!!


Last blog : Alona Beach, Bohol, Philippines
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #18 on: Feb 20, 2007, 12:25:35 PM »

i just cant figure out the part where i can inject the values of a variable ($keyword) into the array.

i think its too advanced for me. does anyone have a formula for this? if not thanks a lot anyway!


Last blog : Alona Beach, Bohol, Philippines
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6274
38470 credits
Members referred : 374


It's time to use PHP5!


« Reply #19 on: Feb 20, 2007, 12:29:59 PM »

what part from this code don't you understand?

$keyword_array[] = "value";

Smiley


Last blog : 4th of July Lottery from TemplateMonster.com
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6032
Tags : keywords search engines Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] 2 Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Ads Triggered by Keywords Used to Get To My Site From Search Engines
« previous next »
Jump to: