News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Adding Google ads UNDER the first post

Started by spiros, April 01, 2005, 10:54:48 AM

Previous topic - Next topic

spiros

I searched the forum thoroughly but I could only find  this post http://www.simplemachines.org/community/index.php?topic=26917.0 which was close but not exactly what I want.

This is what I get with the above:
http://www.translatum.gr/forum/index.php/topic,57.0.html

What I want is this: as soon as a post is made, to have a google ad appear underneath it. If then there is a reply then it appears undeneath the google ad block. You can see what I mean here:

http://www.translatorscafe.com/cafe/MegaBBS/thread-view.asp?threadid=4353&posts=5

Hmm, this was moved to mod requests, I am sure it is just a tiny hack though.

spiros

I did find a solution finally... By myself! It took me a while to properly integrate is as an extra message between first and second message. The only problem is that when no ad is available there is an empty space with 60 pixels height... and I found no way of getting rid that.

See the ad working here
http://www.translatum.gr/forum/index.php/topic,272.0.html

FIND THIS (display template)


// Show the member's signature?
if (!empty($message['member']['signature']) && empty($options['show_no_signatures']))
echo '
<hr width="100%" size="1" class="hrcolor" />
<div style="overflow: auto; width: 100%; padding-bottom: 3px;" class="signature">', $message['member']['signature'], '</div>';

echo '
</td>
</tr>
</table>
</td></tr>
</table>
</td></tr>';
}


Add just before the } at the end there add:

echo '
<tr align=center><td style="padding: 0 0 1px 0; border: 1px solid #7A7777; background-color: #6B8EAE;">
<script type="text/javascript"><!--
google_ad_client = "pub-6539986036551354";
google_alternate_ad_url = "http://www.translatum.gr/empty.html";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_channel ="1128379812";
google_color_border = "6B8EAE";
google_color_bg = "6B8EAE";
google_color_link = "000000";
google_color_url = "666666";
google_color_text = "333333";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td></tr>';

hartiberlin

Hi,
I tried it in my forum,
at www.overunity.com
and I always get ads with are not in the right topic
of my site.

What did you do to get the right ads for your topic ?

What are these codes
google_alternate_ad_url = "http://www.translatum.gr/empty.html";

and
google_ad_channel ="1128379812";

for ?
Can you tell Google with it, what kind of ads content should be displayed ?

I also get 2 ads from the top displayed.
How can you change this, so that 1 ad is displayed at the top
and the other is displayed at the buttom of the thread ?
Many thanks.

Regards. Stefan.

spiros

Check
http://www.google.com/adsense/

their FAQ is quite good and most of your answers will be answered there.

hartiberlin

Hi Spiros,
could you please tell me at least, what you changed, so your
ads are on topic ?
My ads are way off topic over at my site...

Hmmm...
Many thanks.

regards, Stefan.

TMF

Topic of ads is automatically decided by proprietary Google algorithms. You can only improve it by having more on-topic texts, which is hard to control on forums.

hartiberlin

I did not add something like this:
google_alternate_ad_url = "http://www.translatum.gr/empty.html";

Spiros, does this help to stay on topic ?

Thanks.

Regards, Harti.

spiros

No, this only provides an alternative ad from an html file when normally Google would display public service ads.

I recommend you have enough relevant text in your page so that Google picks up the right keywords and displays paid ads.

Webby

I tries this too and it showed me 2 times the adds........

hartiberlin

Yes, I wonder, why it just comes up only 2 times and not more often ?
How is it coded, so that it will display only 2 times and not more ?

Thanks.

Regards, Stefan.
P.S: 2 of the 4 ads are still offtopic in the Google ad at this location at my site.
Only the Google ad in the index.template.php is ontopic.


Ride

Tried this code and the ads come up after the first 2 posts.  On your site it only comes up once.  What did you do?

Ride

nevermind, just need to put this code before:

if ($message['id'] == $context['first_message'])

spiros

Somebody asked me what code I used in order to make a google ad appear on top of the forum, as a message in a board .

Here is the code (default theme, SMF 1.0). I guess you should be able to work out what changes you should make to your own.

// The main content should go here.  A table is used because IE 6 just can't handle a div.
echo '
<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>
<td id="bodyarea" style="padding: 1ex 20px 2ex 20px;">



<div class="tborder">
<table summary="English Greek translation forum, help with French, German, Spanish, Italians language questions and terminology as well as technical help with common computer problems and translation memory tools like Trados, Deja Vu and Wordfast" border="0" width="100%" cellspacing="1" cellpadding="5" height="72">
<tr>
<td  colspan="4" class="catbg2" height="18"><img src="http://www.translatum.gr/forum/Themes/default/images/collapse.gif" border="0" />&nbsp;<u><font size="2">Sponsored translation links</font></u>
</td>
</tr>
<tr class="windowbg2">
<td class="windowbg" width="6%" align="center" valign="middle"><img src="http://www.translatum.gr/forum/Themes/default/images/off.gif" border="0" /></td>
<td align="left" valign="middle">
<script type="text/javascript"><!--
google_ad_client = "pub-6539986036551354";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_channel ="9841008541";
google_color_border = "EFEFEF";
google_color_bg = "EFEFEF";
google_color_link = "000000";
google_color_url = "000000";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>


<td valign="middle" align="center" style="width: 12ex; background-color: #DFDFDF">
<p align="center"><font size="1">1 Post in<br>1 Topic</font></td>
<td align="left" width="22%">
<font size="1">Last Post on April 04, 2005,<br>12:00:00 PM<br>in <u>English dictionary</u> by <u>Google</u></font></td>

</tr>
</table>
</div>';
}
function template_main_below()


hartiberlin

Hi all,
how could this be implemented into the SMF template code ?

http://www.digital-world.info/viewtopic/t-2646.html

There they put the adsense code in every posting of the first user
of a page automatically.

It seems this generates better keywords for the ads so the ads
are more ontopic !

Any idea which template file to edit for this and how ?
Thanks.

Regards, Stefan.

spiros

In order for the ads to be on topic your text has to contain keywords fow which people are paying ads. If not, no matter where you put it in your template you will not get ads on topic. Moreover, if Google has not crawled your page you will not get ads on topic either, even if your text is right.

hartiberlin

Where should I put the keywords ?
I have some keywords in the metatgas in the index.template.php
file and at the top of my forum
overunity.com
they are ontopic, but not inside the single postings...
Hmm...
how do I also know, that Google already crawled my website ?

Thanks.

Regards, Stefan.

spiros

The words should be in your content. If your content is irrelevant, Google ads will be most likely public service ads. Have you enabled search engine friendly URLs? It helps.

hartiberlin

Yes, my users post normal text ontopic there in the forum,
mostly alternative energy research related,
but the Google ads is then about password protection and such stuff,
totally unrelated...

Yes, I have enabled search engine friendly URLs.

Regards, Stefan.

spiros

This means:

1) No appropriate ads exist for these keywords found in your posts
2) Google has not yet crawled the specific page

hartiberlin

Well, when I create a new topic, then it is probably
always so, that Google did not yet crawl the page,
as it did not exist yet...
I did put at least remarks <! keyword1 keyword2>
around the google adsense code inside the template,
but that did not help either....
Hmm, so it seems the newer topics might not have been
crawled by google yet and that is why the ads are offtopic...

Regards, Stefan.

spiros

Unless your site is extremely popular (i.e. a portal) Google will NOT crawl new posts immediately. It might even take days or weeks.

Dinagyang

Hehe thanks for this code. I have it for vbulletin as well.

brucebeh


vdubbia

I got the code to work but it only put the ad under the first post and put a 'blank' ad under all the other posts.

Can you clarify how to remove that blank ad under the remaining posts on the boards?

mennou

thanks for te code.. it works like a baby 

hartiberlin

Quote from: wowzer on August 13, 2005, 10:15:07 AM
I got the code to work but it only put the ad under the first post and put a 'blank' ad under all the other posts.

Can you clarify how to remove that blank ad under the remaining posts on the boards?

I have the same problem, that I can not control,
how many ads are delivered in a thread.

Where can one set it this way, that every 5 postings an ad will
be displayed in between ?

Thanks.

Regards, Stefan.

vdubbia

Can someone let us know how to remove the blank ad space that is created under every post after the 1st one with this script?

aabce

Quote from: spiros on May 11, 2005, 04:34:01 PM
Somebody asked me what code I used in order to make a google ad appear on top of the forum, as a message in a board [nofollow] .

Here is the code (default theme, SMF 1.0). I guess you should be able to work out what changes you should make to your own.

// The main content should go here.  A table is used because IE 6 just can't handle a div.
echo '
<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>
<td id="bodyarea" style="padding: 1ex 20px 2ex 20px;">



<div class="tborder">
<table summary="English Greek translation forum, help with French, German, Spanish, Italians language questions and terminology as well as technical help with common computer problems and translation memory tools like Trados, Deja Vu and Wordfast" border="0" width="100%" cellspacing="1" cellpadding="5" height="72">
<tr>
<td  colspan="4" class="catbg2" height="18"><img src="http://www.translatum.gr/forum/Themes/default/images/collapse.gif" border="0" />&nbsp;<u><font size="2">Sponsored translation links</font></u>
</td>
</tr>
<tr class="windowbg2">
<td class="windowbg" width="6%" align="center" valign="middle"><img src="http://www.translatum.gr/forum/Themes/default/images/off.gif" border="0" /></td>
<td align="left" valign="middle">
<script type="text/javascript"><!--
google_ad_client = "pub-6539986036551354";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_channel ="9841008541";
google_color_border = "EFEFEF";
google_color_bg = "EFEFEF";
google_color_link = "000000";
google_color_url = "000000";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>


<td valign="middle" align="center" style="width: 12ex; background-color: #DFDFDF">
<p align="center"><font size="1">1 Post in<br>1 Topic</font></td>
<td align="left" width="22%">
<font size="1">Last Post on April 04, 2005,<br>12:00:00 PM<br>in <u>English dictionary</u> by <u>Google</u></font></td>

</tr>
</table>
</div>';
}
function template_main_below()



what files i should edit? iuse SMF 1.1 Beta 3 Public.

please post real source code

Neol

Spiro, can you make the adds appear like normal posts and users? I have seen a phpbb forum that have google adds in that way. ::)

spiros

Quote from: olti on September 08, 2005, 05:06:39 PM
Spiro, can you make the adds appear like normal posts and users? I have seen a phpbb forum that have google adds in that way. ::)

Hello Olti,

I am not sure exactly what you want it to look like. Please provide a link.

Advertisement: