Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > Management Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
vBulletin Google Adsense Deep Integration Tutorial
NeutralizeR
Join Date: Aug 2005
Posts: 355

 

Show Printable Version Email this Page Subscription
NeutralizeR NeutralizeR is offline 02-13-2006, 10:00 PM

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:

Quote:
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:
Quote:
<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:
Quote:
<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:
Quote:
<!-- / PAGENAV POPUP -->
</if>
Add below:
Quote:
<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:
Quote:
<if condition="$show['threads']">
Add below:
Quote:
<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:
Quote:
<!-- end show threads -->
Add below:
Quote:
<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.

https://vborg.vbsupport.ru/showthread.php?t=102466


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

(First result)

Find:
Quote:
$searchbits

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

<else />
Add below:
Quote:
<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:
Quote:
</tr>
$searchbits
Add below:
Quote:
<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:




Save.


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

(First post and last shown post)

Find:
Quote:
<!-- / message -->
Add below:
Quote:
<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.
https://vborg.vbsupport.ru/showpost....30&postcount=7

Results:





vBulletin Google Adsense Deep Integration Tutorial by NeutralizeR @ www.MsXLabs.org
Reply With Quote
  #142  
Old 06-01-2008, 02:14 AM
nirvana43's Avatar
nirvana43 nirvana43 is offline
 
Join Date: Oct 2007
Location: Pune, India
Posts: 361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i've implemented this!! but there are 3 errors...
please check this link : http://validator.w3.org/check?uri=ht...Inline&group=0

how do i fix those 3 errors???
Reply With Quote
  #143  
Old 06-16-2008, 04:20 AM
nirvana43's Avatar
nirvana43 nirvana43 is offline
 
Join Date: Oct 2007
Location: Pune, India
Posts: 361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have 1 question,
when we place ads in navbar i.e. :


this unit is displayed only when user is logged in.... please can you tell me, what if i want to display this unit for guests too??
where do i place the code and is there any code modifications??? please help..
i'm not a pro coder...
Reply With Quote
  #144  
Old 06-22-2008, 05:04 PM
munnakv munnakv is offline
 
Join Date: Jun 2008
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Fantastic tutorial. bookmarked it. Will read it soon.

Thanks.
Reply With Quote
  #145  
Old 06-23-2008, 05:30 PM
Declan127 Declan127 is offline
 
Join Date: Jan 2008
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

One of the best Tutorials ive seen in a while.

Cheers =]
Reply With Quote
  #146  
Old 06-30-2008, 02:48 PM
jalmz's Avatar
jalmz jalmz is offline
 
Join Date: Aug 2005
Posts: 90
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

wow.. thanks!
Reply With Quote
  #147  
Old 07-02-2008, 02:14 PM
glenbelt glenbelt is offline
 
Join Date: Apr 2008
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Added this code to my forum and it seems good but I have one problem.

My link unit is at the top of the forum but below this there is an empty strip. I'm not sure if this was there before I made the changes to the forum, and was wondering if that is where I am meant to be displaying the Ad Unit?

Have attached a screenshot below.



Thanks for any help.
Reply With Quote
  #148  
Old 07-02-2008, 04:56 PM
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
Posts: 355
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's the first ad unit (728 x 90). Check your navbar edits again. You should know that Google has changed the ad codes incase you are using the ones in this tutorial. If you have just put the ads in your pages, wait a couple of days for the adsense bot to crawl your pages.
Reply With Quote
  #149  
Old 07-03-2008, 08:12 AM
glenbelt glenbelt is offline
 
Join Date: Apr 2008
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks NeutralizeR.

I realised that Google had changed their ad codes, but I was a bit confused. Firstly I used the new adsense codes, and then I realised that I had missed out the line of code mentioning the collapsible ad unit html page, so then I went and changed all my adverts over to the style of the ones in the article.

Should I just use the newer adsense codes?

Also would I simply link to the collapsible ad unit.html file from within adsense, where they ask me about showing alternative adverts instead of PSA ones?

Thanks for any help
Reply With Quote
  #150  
Old 07-03-2008, 09:12 AM
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
Posts: 355
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by glenbelt View Post
Thanks NeutralizeR.

I realised that Google had changed their ad codes, but I was a bit confused. Firstly I used the new adsense codes, and then I realised that I had missed out the line of code mentioning the collapsible ad unit html page, so then I went and changed all my adverts over to the style of the ones in the article.

Should I just use the newer adsense codes?

Also would I simply link to the collapsible ad unit.html file from within adsense, where they ask me about showing alternative adverts instead of PSA ones?


Thanks for any help
Yes, use the new adsense codes and enter the link of the collapsible html within adsense.
Reply With Quote
  #151  
Old 07-03-2008, 09:42 AM
glenbelt glenbelt is offline
 
Join Date: Apr 2008
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh okay, thanks again NeutralizeR.

Can I just ask, what does the collapsible ad unit do? What does it show?

Thanks again
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:47 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06651 seconds
  • Memory Usage 2,361KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_html
  • (16)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (3)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete