Back to Management Articles

vBulletin Google Adsense Deep Integration Tutorial
by NeutralizeR 14 Feb 2006

This tutorial is written to show you how to use your Google Adsense codes efficiently in your vBulletin (3.5+) templates. I have a very heavily modified vBulletin style but i used the original style for this tutorial to be simple and match the colors. You can change everything as you want to find the most fitting results for your vBulletin.

Alternate ads-PSAs to Collapsible ads:

Collapsing ad units are an optional advanced feature of alternate ads. A+ the collapsing ad unit code will 'collapse' your ad unit so that it takes up no page space if there are no relevant ads available. This allows you to minimize any blank space that would otherwise occur through the use of alternate colors.

To implement the collapsing ad units feature, you'll need to host a small HTML file on your domain. Your alternate ad URL will reference this file, which will be called if there are no ads available for that particular ad unit.
http://joomla.medspan.info/forum/index.php/topic,57.0.html
Create a HTML file with this code and save it as collapsible_ad.html:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<script src="http://pagead2.googlesyndication.com/pagead/google_adsense_script.js" type="text/javascript"></script>
</head>
<body style="background-color: transparent;">
</body>
</html>
Upload this file to your web server. (http://www.yourwebsite.com/collapsible_ad.html)

Go to your Google Adsense account and grap your google_ad_client and google_ad_channel codes. (google_ad_channel is optional)

Open Notepad and paste these codes as you will change them with youradsensecode and yourchannelcode on the following steps.

We will use these there ad layouts in this tutorial:

728 x 90 Leaderboard
468 x 60 Banner
234 x 60 Half Banner

...and one link unit:

468 x 15

Note: navbar template editing step is optional because it may be against the Google Adsense rules for you. If you edit navbar template, almost all of your vBulletin pages will have Adsense ads at the top of the pages. My navbar and header templates include some flash, gif and text content and i update them regularly. It's why i use Adsense ads in navbar. You may apply this step (the ad unit) manually to your FORUMHOME, FORUMDISPLAY, etc templates...

Open your navbar template: vBulletin AdminCP > Styles & Templates > Edit Templates > Navigation / Breadcrumb Templates > navbar

(for the link unit)

Find:
<div class="navbar" style="font-size:10pt"><a href="$vboptions[forumhome].php$session[sessionurl_q]" accesskey="1"><img class="inlineimg" src="$stylevar[imgdir_misc]/navbits_start.gif" alt="" border="0" /></a> <strong>$vboptions[bbtitle]</strong></div>
</if>
Add below:
<script type="text/javascript"><!--
google_ad_client = "youradsensecode";
google_alternate_ad_url = "http://www.yourwebsite.com/collapsible_ad.html";
google_ad_width = 468;
google_ad_height = 15;
google_ad_format = "468x15_0ads_al_s";
google_ad_channel ="yourchannelcode";
google_color_border = "F5F5FF";
google_color_bg = "F5F5FF";
google_color_link = "22229C";
google_color_url = "000000";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
Results:




(for the ad unit)

Find:
<!-- / PAGENAV POPUP -->
</if>
Add below:
<table class="tborder" cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
<tr>
<td class="alt1" align="center">
&nbsp;<script type="text/javascript"><!--
google_ad_client = "youradsensecode";
google_alternate_ad_url = "http://www.yourwebsite.com/collapsible_ad.html";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
google_ad_channel ="yourchannelcode";
google_color_border = "F5F5FF";
google_color_bg = "F5F5FF";
google_color_link = "FF0000";
google_color_url = "000000";
google_color_text = "22229C";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>&nbsp;
</td>
</tr>
</table><br />
Results:




Save.

Open your FORUMDISPLAY template: vBulletin AdminCP > Styles & Templates > Edit Templates > Forum Display Templates > FORUMDISPLAY

(First thread)

Find:
<if condition="$show['threads']">
Add below:
<tr>
<td align="center" class="alt1">-</td>
<td align="center" class="alt2">-</td>
<td class="alt1">
<div>
<script type="text/javascript"><!--
google_ad_client = "youradsensecode";
google_alternate_ad_url = "http://www.yourwebsite.com/collapsible_ad.html";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="yourchannelcode";
google_color_border = "F5F5FF";
google_color_bg = "F5F5FF";
google_color_link = "22229C";
google_color_url = "000000";
google_color_text = "22229C";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</td>

<td class="alt2 smallfont" align="center">Sponsored Links</td>

<td class="alt1" align="center">-</td>
<td class="alt2" align="center">-</td>
<if condition="$show['inlinemod']"><td class="alt1" align="center">-</td></if>

</tr>

(Last thread)

Find:
<!-- end show threads -->
Add below:
<tr>
<td align="center" class="alt1">-</td>
<td align="center" class="alt2">-</td>
<td class="alt1">
<div>
<script type="text/javascript"><!--
google_ad_client = "youradsensecode";
google_alternate_ad_url = "http://www.yourwebsite.com/collapsible_ad.html";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="yourchannelcode";
google_color_border = "F5F5FF";
google_color_bg = "F5F5FF";
google_color_link = "22229C";
google_color_url = "000000";
google_color_text = "22229C";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</td>

<td class="alt2 smallfont" align="center">Sponsored Links</td>

<td class="alt1" align="center">-</td>
<td class="alt2" align="center">-</td>
<if condition="$show['inlinemod']"><td class="alt1" align="center">-</td></if>

</tr>
Results:




Save.

Adsense below the last thread

Open your search_results template: vBulletin AdminCP > Styles & Templates > Edit Templates > Search Templates > search_results

(First result)

Find:
$searchbits

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">

<else />
Add below:
<tr>
<td align="center" class="alt1">-</td>
<td align="center" class="alt2">-</td>
<td class="alt1">
<div>
<script type="text/javascript"><!--
google_ad_client = "youradsensecode";
google_alternate_ad_url = "http://www.yourwebsite.com/collapsible_ad.html";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
google_ad_channel ="yourchannelcode";
google_color_border = "F5F5FF";
google_color_bg = "F5F5FF";
google_color_link = "22229C";
google_color_url = "000000";
google_color_text = "22229C";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</td>

<td class="alt2 smallfont" align="center">Sponsored Links</td>

<td class="alt1" align="center">-</td>
<td class="alt2" align="center">-</td>
<td class="alt1" align="center">-</td>
<if condition="$show['inlinemod']"><td class="alt1" align="center">-</td></if>

</tr>

(Last result)

Find:
</tr>
$searchbits
Add below:
<tr>
<td align="center" class="alt1">-</td>
<td align="center" class="alt2">-</td>
<td class="alt1">
<div>
<script type="text/javascript"><!--
google_ad_client = "youradsensecode";
google_alternate_ad_url = "http://www.yourwebsite.com/collapsible_ad.html";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
google_ad_channel ="yourchannelcode";
google_color_border = "F5F5FF";
google_color_bg = "F5F5FF";
google_color_link = "22229C";
google_color_url = "000000";
google_color_text = "22229C";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</td>

<td class="alt2 smallfont" align="center">Sponsored Links</td>

<td class="alt1" align="center">-</td>
<td class="alt2" align="center">-</td>
<td class="alt1" align="center">-</td>
<if condition="$show['inlinemod']"><td class="alt1" align="center">-</td></if>

</tr>
Results:
http://img302.imageshack.us/my.php?image=snap98ab.gif



Save.

Open your postbit(legacy) template: vBulletin AdminCP > Styles & Templates > Edit Templates > Postbit Templates > postbit(legacy)

(First post and last shown post)

Find:
<!-- / message -->
Add below:
<if condition="(($post[postcount]==1) or ($post[islastshown] and !$GLOBALS['vbulletin']->GPC['ajax']))">
<center>
<script type="text/javascript"><!--
google_ad_client = "youradsensecode";
google_alternate_ad_url = "http://www.yourwebsite.com/collapsible_ad.html";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="yourchannelcode";
google_color_border = "F5F5FF";
google_color_bg = "F5F5FF";
google_color_link = "FF0000";
google_color_url = "000000";
google_color_text = "22229C";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</center>
</if>
Save.

Spoiler (click to open)


What's more fun and challenging - because of ajax issues, is adsense in the last post. That really gets the ad right where the reader's eyes are.

http://www.eaforums.com/forums/364919-post1.html

Find:
Code:
<!-- message -->
		<div id="post_message_$post[postid]">$post[message]</div>
		<!-- / message -->
Add above:
Code:
		<if condition="(($post[postcount]==1) or ($post[islastshown] and !$GLOBALS['vbulletin']->GPC['ajax']))">
<span id="google" style="float:left;margin:2px;" width="340" height="290" align="center" valign="top">
put banner code here
</span></if>

Close


Results:


http://img441.imageshack.us/my.php?image=snap87bw.gif

vBulletin Google Adsense Deep Integration Tutorial by http://www.msxlabs.org/forum/members/1-neutralizer.html @ http://www.MsXLabs.org

Similar Mods

Show Thread Enhancements Google Adsense Postbit Integration vBulletin 3.8 Add-ons
Integration with vBulletin CFM: Google AdSense for Search Integration vBulletin 3.6 Add-ons
Show Thread Enhancements Google Adsense Postbit Integration vBulletin 3.7 Add-ons
Add-On Releases vB Google Adsense for Search plus Integration vBulletin 3.6 Add-ons

vblts.ru supports vBulletin®, 2022-2024