PDA

View Full Version : Targeted ads for phpAdsNew


unixman
21 Jun 2001, 02:12
Giving back some more ...

We have 30+ forums, all dedicated to different topics. I wanted to be able to sell targeted banner ads for each of those categories. phpAdsNew is great for serving ads, but I needed to make some quick changes to VB in order to facilitate targeting.

Its easy to just plop in a generic call to phpAdsNew in the "header" template - works easy enough - however, you have no control and no ability to dynamically target those ads to a given forum. Now you can. (If there is another way, someone please tell me).

This is a simple hack, which involves a quick change to "global.php".

In global.php, find:


// figure out the chosen style settings


Below that, add:


// figure out the chosen style settings

// BSB - HACK - Need to populate foruminfo for targeted ads
if(isset($forumid)) {
$getforuminfo=$DB_site->query_first("SELECT title FROM forum WHERE forumid='$forumid'");
$forum_ad_keywords=$getforuminfo[title];

// Replace generic words
$forum_ad_keywords = str_replace(" and ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" the ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" with ", " ", $forum_ad_keywords);
$forum_ad_keywordss = str_replace(" or ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace("/", " ", $forum_ad_keywords);

// Replace spaces with commas (for phpAdsNew OR keywords)
$forum_ad_keywords = str_replace(" ", ",", $forum_ad_keywords);
}
// END HACK



Let me give you an example. Let's say you have 2 forums:


Outdoor Hiking
Wild and Crazy Sex


Strange combination, I know - but bear with me. This hack will create a special variable called "$forum_ad_keywords", which will look like this (using the 2 examples above):


Outdoor,Hiking
Wild,Crazy,Sex


To use these in a template (i.e. header) to grab a target ad, you might try something like:


<a href="/ads/admin/adclick.php?n=$VBRandomX"><img src="/ads/admin/adview.php?n=$VBRandomX&what=$forum_ad_keywords" border="0"></a>


Note: the VBRandomX numbers are another hack. Just put this line in global.php to get some random #'s for the ad call:


$VBRandomX = time();


Easy enough. Not a real great randomizer, but it works for my needs. You want it to do more, have at it.

At any rate, the ad code above would expand to something like:


<a href="/ads/admin/adclick.php?n=993088616"><img src="/ads/admin/adview.php?n=993088616&what=Outdoor,Hiking" border="0"></a>


Now all you need to do is use those keywords when creating accounts within phpAdsNew.

Voila - instant targeted ads.

A robust, scalable targeted ad/sponsorship system should really be a part of the next release - IMHO.

Cheers.

Pingu
21 Jun 2001, 21:39
I already have ads targeting forums (by their names).

But the problem is just there: those names can get pretty long, and all keywords together for one single banner can make a pretty long line.

So my next step is to add an extra field, with something like forum_short_name
I've tried the forumnumber, but it doesn't work (because the number is a number and not text or something?! I don't know PHP/MySQL well enough)

But a hack like this one is very good :)

eva2000
21 Jun 2001, 21:46
wow this looks fantastic, i'm using phpadsnew as well on my vB http://animeboards.com

but it does lack targetted ads... gonna try this out

JonnyQuest
22 Jun 2001, 19:08
Is there anyway you can make this so it pulls the actual title tag of the page? I'm using it to make a keyword search in my store.
Thanks!

Byron
29 Jun 2001, 01:13
this is a useful hack. thanks

Byron
29 Jun 2001, 01:26
this is a useful hack. thanks

Lionel
25 Jan 2002, 13:12
thanks

mvigod
14 Feb 2002, 16:59
what is the "n=" mean and why bother with the VbRandomX thing you have in this? Is the random thing just for cache busting or does it serve any other purpose?

mvigod
17 Feb 2002, 00:54
I changed just a little...

// figure out the chosen style settings
// BSB - HACK - Need to populate foruminfo for targeted ads
//if(isset($forumid)) {
// $getforuminfo=$DB_site->query_first("SELECT title FROM forum WHERE forumid='$forumid'");
// $forum_ad_keywords=strtolower($getforuminfo[title]);

// Replace generic words
// $forum_ad_keywords = str_replace(" and ", " ", $forum_ad_keywords);
// $forum_ad_keywords = str_replace(" the ", " ", $forum_ad_keywords);
// $forum_ad_keywords = str_replace(" with ", " ", $forum_ad_keywords);
// $forum_ad_keywords = str_replace(" or ", " ", $forum_ad_keywords);
// $forum_ad_keywords = str_replace("/", " ", $forum_ad_keywords);
// $forum_ad_keywords = str_replace(" & ", " ", $forum_ad_keywords);
// $forum_ad_keywords = str_replace(" for ", " ", $forum_ad_keywords);

// Replace spaces with commas (for phpAdsNew OR keywords)
// $forum_ad_keywords = str_replace(" ", ",", $forum_ad_keywords);
//} else {
// $forum_ad_keywords = 'home';
// }

// END HACK

X-Fan
17 Feb 2002, 07:45
Just wondering how difficult would it be to incorporate phpAdsNew on a board that runs the vbPortal front end (as it has its own banner rotation system)?

mvigod
17 Feb 2002, 15:22
I don't think it would be very hard...check out www.ezonemag.com as I think they do it.

as far as targeting to forums I would imagine it's much of the same procedure although I don't have vbportal so not 100% sure.

rinkrat
30 Mar 2002, 06:45
Where can I get VBRandomX?

I need some random numbers!

SAWolf76
08 Apr 2002, 00:51
can someone please update this hack? I would like to install it but its kind of confusing and old....

Dejan
11 May 2002, 21:44
Thanks ...

But how to show ads taken from parent forum inside thread pages?

PurpleCow
29 Mar 2003, 15:15
Hello,

If anyone is using this hack, kindly reply.

I seriously want this hack in working condition for my new vB ver2.3.0.

Any changes in the code..??

Thanks for your help

cnczone
11 Apr 2003, 23:32
Any new info on this subject?

PurpleCow
12 Apr 2003, 03:29
I am also interested in this...!!

Does it work with 2.3.0 ??

Thanks much

trafix
12 Apr 2003, 03:45
I have just removed phpadsnew from my server.... its to confusing and takes ages to add a new banner, whatever...

click on >>--ARROW ADS--> in my sig.

hope this helps :)

cnczone
12 Apr 2003, 05:20
I got it to work find but I what to use the hack in this thread, to target forums. here is my site using phpadsnew http://cnczone.com

PurpleCow
12 Apr 2003, 07:14
Today at 10:09 AM trafix said this in Post #18 (http://www.vbulletin.org/forum/showthread.php?postid=380899#post380899)
I have just removed phpadsnew from my server.... its to confusing and takes ages to add a new banner, whatever...

click on >>--ARROW ADS--> in my sig.

hope this helps :)


I don't deny the power of ur hack trafix...but the beauty of phpadsnew is the kind of features and most importantly, it can be used to serve ads for a network of sites rather than just one site.

Thanks if you can help us with integrating phpadsnew !

Thanks again

Dejan
22 Apr 2003, 23:31
It works fine in vB 2.30. I am using this code:



// figure out the chosen style settings
// BSB - HACK - Need to populate foruminfo for targeted ads
if(isset($forumid)) {
$getforuminfo=$DB_site->query_first("SELECT title FROM forum WHERE forumid='$forumid'");
$forum_ad_keywords=strtolower($getforuminfo[title]);

// Replace generic words
$forum_ad_keywords = str_replace(" and ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" the ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" with ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" or ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace("/", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" & ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" for ", " ", $forum_ad_keywords);

// Replace spaces with commas (for phpAdsNew OR keywords)
$forum_ad_keywords = str_replace(" ", ",", $forum_ad_keywords);
} else {
$forum_ad_keywords = 'home';
}



// Parent forum inside thread pages
if(isset($threadid)) {
$getforuminfo=$DB_site->query_first("SELECT forum.title FROM forum,thread WHERE threadid='$threadid' AND forum.forumid=thread.forumid");

$forum_ad_keywords=strtolower($getforuminfo[title]);

// Replace generic words
$forum_ad_keywords = str_replace(" and ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" the ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" with ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" or ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace("/", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" & ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" for ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" i ", " ", $forum_ad_keywords);

// Replace spaces with commas (for phpAdsNew OR keywords)
$forum_ad_keywords = str_replace(" ", ",", $forum_ad_keywords);
}

// END HACK

cnczone
23 Apr 2003, 03:47
Where do I install it?

Dejan
23 Apr 2003, 10:12
It is the same hack, only add on is for putting keywords of parent forum inside thread pages.

In global.php, find:
// figure out the chosen style settings

Below that, add:
// BSB - HACK - Need to populate foruminfo for targeted ads
if(isset($forumid)) {
$getforuminfo=$DB_site->query_first("SELECT title FROM forum WHERE forumid='$forumid'");
$forum_ad_keywords=strtolower($getforuminfo[title]);

// Replace generic words
$forum_ad_keywords = str_replace(" and ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" the ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" with ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" or ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace("/", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" & ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" for ", " ", $forum_ad_keywords);

// Replace spaces with commas (for phpAdsNew OR keywords)
$forum_ad_keywords = str_replace(" ", ",", $forum_ad_keywords);
} else {
$forum_ad_keywords = 'home';
}



// Parent forum inside thread pages
if(isset($threadid)) {
$getforuminfo=$DB_site->query_first("SELECT forum.title FROM forum,thread WHERE threadid='$threadid' AND forum.forumid=thread.forumid");

$forum_ad_keywords=strtolower($getforuminfo[title]);

// Replace generic words
$forum_ad_keywords = str_replace(" and ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" the ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" with ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" or ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace("/", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" & ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" for ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" i ", " ", $forum_ad_keywords);

// Replace spaces with commas (for phpAdsNew OR keywords)
$forum_ad_keywords = str_replace(" ", ",", $forum_ad_keywords);
}

// END HACK

I am using old version of phpAdsNew and Remote Invocation with JavaScript. For that, in header template put:


<script language="JavaScript" src="http://www.your.path.to.phpadsnew/adjs.php?what=$forum_ad_keywords,+468x60&target=_blank">
</script>


Change 468x60 for the banner size you are using.

cnczone
23 Apr 2003, 22:43
Thanks for your help, now once I put the code in how do I call a banner to a fourm, do I use the forum name?

Dejan
24 Apr 2003, 18:07
Yes, just use forum name as keyword.

cnczone
24 Apr 2003, 19:58
but the banner has to be the right size right? I can just use any banners of different sizes correct?

Dejan
26 Apr 2003, 07:37
PhpAdsNew is powerful application, you can us any banner and any size of banner. Look in phpAdsNew user-guide for banner invocation code statements and adapt it for your needs.

Imprezer
23 May 2003, 03:24
Ok, so I copy pasted the code from Dejan's post below the "// figure out the chosen style settings".

Then I added key words for banners replacing space in forum name with a ,.

It doesnt work.

I got banners all over the site. It doesnt seem to be looking at the keywords.

What am I doing wrong?

Imprezer
23 May 2003, 03:42
Nevermind.

I figured it out.

Works like a charm.

Imprezer
23 May 2003, 04:49
Hmm, it works, but I need help.

I have 2 forums.

FOR SALE BY VENDORS
FOR SALE BY MEMBERS

How can I type in the keywords, so that when I type: for,sale,by,vendors since there is "by" in the forum title #2, the banner would only show up in the the vendor forum and not the member one.

Thanks!

Dejan
23 May 2003, 09:20
try to not use "by" as keyword
or
try to add "by" in //Replace generic words


Code for your global.php is:


// BSB - HACK - Need to populate foruminfo for targeted ads
if(isset($forumid)) {
$getforuminfo=$DB_site->query_first("SELECT title FROM forum WHERE forumid='$forumid'");
$forum_ad_keywords=strtolower($getforuminfo[title]);

// Replace generic words
$forum_ad_keywords = str_replace(" and ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" the ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" with ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" or ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace("/", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" & ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" for ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" by", " ", $forum_ad_keywords);

// Replace spaces with commas (for phpAdsNew OR keywords)
$forum_ad_keywords = str_replace(" ", ",", $forum_ad_keywords);
} else {
$forum_ad_keywords = 'home';
}



// Parent forum inside thread pages
if(isset($threadid)) {
$getforuminfo=$DB_site->query_first("SELECT forum.title FROM forum,thread WHERE threadid='$threadid' AND forum.forumid=thread.forumid");

$forum_ad_keywords=strtolower($getforuminfo[title]);

// Replace generic words
$forum_ad_keywords = str_replace(" and ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" the ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" with ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" or ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace("/", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" & ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" for ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" i ", " ", $forum_ad_keywords);
$forum_ad_keywords = str_replace(" by", " ", $forum_ad_keywords);

// Replace spaces with commas (for phpAdsNew OR keywords)
$forum_ad_keywords = str_replace(" ", ",", $forum_ad_keywords);
}

// END HACK

cleck673
10 Jul 2003, 06:35
Is anyone still using this. I can not get it working.

Beowulf33
13 Jul 2003, 08:59
I have this hack working fine on 2.3.0

Beowulf33
16 Aug 2003, 02:39
I now have this working fine on 3.0 beta 5 as well

Tuan Le
02 Sep 2003, 14:43
I got this added to the phpinclude_start


require("C:/../../phpadsnew/phpadsnew.inc.php");
if (!isset($phpAds_context)) $phpAds_context = array();
$phpAds_raw = view_raw ('', 0, '', '', '0', $phpAds_context);
$variable_name = $phpAds_raw['html'];



But not sure where I need to put the local invocation code generated by phpadsnew. Do you know where I need to put them? I would greatly appreciated if you can point me to the right direction. :confused: Thanks.


<?php
if (@include('C:/../../phpadsnew/phpadsnew.inc.php')) {
if (!isset($phpAds_context)) $phpAds_context = array();
$phpAds_raw = view_raw ('', 2, '', '', '0', $phpAds_context);
echo $phpAds_raw['html'];
}
?>

Imprezer
03 Oct 2003, 04:24
So far it is working great.

Is there any way to plug a banner on the main forum page? Forum Home I mean.

Thanks!

- Alex

AmericanWoman
20 Oct 2003, 19:15
I haven't been able to get the size parameters working properly...if I try to specify a size, the banner disappears altogether. :(

Here is the invocation code I'm testing (remote javascript method):


<!--
if (!document.phpAds_used) document.phpAds_used = ',';
phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);

document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://www.acuraworld.com/ads/adjs.php?n=" + phpAds_random);
document.write ("&amp;what=$forum_ad_keywords@width:120");
document.write ("&amp;exclude=" + document.phpAds_used);
if (document.referer)
document.write ("&amp;referer=" + escape(document.referer));
document.write ("'><" + "/script>");
//-->
</script><noscript><a href='http://www.acuraworld.com/ads/adclick.php?n=a1d9c3f2' target='_blank'><img src='http://www.acuraworld.com/ads/adview.php?what=home@width:120&amp;source=http%3A%2F%2Fwww.acuraworld.com&amp;n=a1d9c3f2 ' border='0' alt=''></a></noscript>

According to the manual, I replaced the "," delimiters with a "/" and appended the "@" symbol to the end of the string to create a parameter for the entire expression - but it's not working at all. :( I've checked the output of the code to be sure it's picking up the keywords variable, and it is...

Any ideas?