Page 1 of 2

Adsense Channel ID's

Posted: April 7th, 2008, 7:25 pm
by squidmarks
Paul,

Thanks for creating the great Adsense extension for WikiMedia. I'm trying to use it for my wiki, http://ipodifier.com/wiki, and have had some success, but I still don't really get the Adsense channel thing. I thought Adsense channels were a way to track your adsense performance, and were not really a link to a specific ad unit. I don't understand why you are not using the ad unit ID number rather than a channel ID. Perhaps I don't really understand how to use channels in Adsense.

Anyway, I do have your Adsense extension working, but I have two different Adsense units, one a content specific one and another a referral. I have them associated with different channels. But, the same ad shows up in my wiki regardless which channel I request.

Again, maybe I need an explanation of how adsense channels relate to ad units.

Thanks.

Geoff

Re: Adsense Channel ID's

Posted: April 9th, 2008, 11:54 pm
by Paul
IMO the channel thing is for you to track which page is hot. :D

Re: Adsense Channel ID's

Posted: April 10th, 2008, 7:41 am
by squidmarks
Paul,

I am able to get an adsense ad to show up on my wiki (http://ipodifier.com/wiki) using your extension, and I have two channels setup, one for a content ad, and one for a referral ad. Now, by referral ad, I don't mean the REF tag that you have that brings up an ad for google adsense, I mean an adsense referral ad where I have selected particular ads that I want to appear on my site that have payouts based upon referrals (perhaps this is obvious). Anyway, I have two channels setup, one for each of these: an Adsense for content and a Referrals channel, and have these in the Settings.php file. No matter which channel I use, I get a generic adsense ad displayed in my wiki. What's more, the size of the referral ad that is displayed is 468x60, not the 728x90 that is in the adsense content channel I have setup. Could it be defaulting to a basic channel if it is not getting correct information?

Thanks for your help.

Geoff

Re: Adsense Channel ID's

Posted: April 10th, 2008, 6:07 pm
by Paul
Yes, all your questions can be done, but you need to code a little bit based on my extension. The extension is pretty clear and easy to understand, and it is also easy to modify. :D

Re: Adsense Channel ID's

Posted: April 10th, 2008, 9:15 pm
by squidmarks
Paul,

Yes, I've been looking at the code. I've changed to the 728 width ads. What I need to do, I think, is switch from using channel id's to using the ad_slot number. That way I can have it display a specific ad. I'll work on that.

Geoff

Re: Adsense Channel ID's

Posted: April 12th, 2008, 9:13 am
by squidmarks
Paul,

Below is a modification to your code that allows specific ads to be displayed using the ad_slot instead of channel_id. The only caveat is that referral ads and content ads need slightly different code, so the user must use "REF" or "CON" as the first three letters when naming the ads in the settings.php file to designate them as referral or content ads.

GoogleAdSense.php

===everything above this is unchanged===
$adType=substr($input,0,3);
foreach($googleads as $adName => $adslot)
{
if($input == $adName )
{
if ($adType=='REF')
$output = gAdSenseforReferral728($clientID, $adslot);
if ($adType=='CON')
$output = gAdSenseforContent728($clientID, $adslot);
}
}

return $output;
}


# The function for Google Content Ad (468x60)
function gAdSenseforContent468($clientID, $adslot ) {
$rc =
"<div id=\"googleContentWrapper\">\n" .
"<p class=\"googleContent\"><script type=\"text/javascript\">\n" .
"google_ad_client = \"$clientID\";\n" .
"google_ad_slot = \"$adslot\";\n" .
"google_ad_width = 468;\n" .
"google_ad_height = 60;\n" .
"</script>\n" .
"<script type=\"text/javascript\" src=\"http://pagead2.googlesyndication.com/pa ... ds.js\">\n" .
"</script></p></div>";

return $rc;
}

# The function for Google Content Ad (728x90)
function gAdSenseforContent728($clientID, $adslot ) {
$rc =
"<div id=\"googleContentWrapper\">\n" .
"<p class=\"googleContent\"><script type=\"text/javascript\">\n" .
"google_ad_client = \"$clientID\";\n" .
"google_ad_slot = \"$adslot\";\n" .
"google_ad_width = 728;\n" .
"google_ad_height = 90;\n" .
"</script>\n" .
"<script type=\"text/javascript\" src=\"http://pagead2.googlesyndication.com/pa ... ds.js\">\n" .
"</script></p></div>";

return $rc;
}

# The function for Google Referral Ad (728x90)
function gAdSenseforReferral728($clientID, $adslot ) {
$rc =
"<div id=\"googleContentWrapper\">\n" .
"<p class=\"googleContent\"><script type=\"text/javascript\">\n" .
"google_ad_client = \"$clientID\";\n" .
"google_ad_slot = \"$adslot\";\n" .
"google_ad_width = 728;\n" .
"google_ad_height = 90;\n" .
"google_cpa_choice = \"\";\n" .
"</script>\n" .
"<script type=\"text/javascript\" src=\"http://pagead2.googlesyndication.com/pa ... ds.js\">\n" .
"</script></p></div>";

return $rc;
}

?>

Settings.php
== Everything above this is unchanged ==

$clientID = "pub-xxxxxxxxxxxxxxxxxxxxx";

// Your Google ad info, which is from Google Adsense
$googleads = array(
'CONAd'=> '7948880220',
'REFAd'=> '7136561570'
);

?>

Re: Adsense Channel ID's

Posted: April 13th, 2008, 10:49 pm
by Paul
Thanks for great work :D .

Re: Adsense Channel ID's

Posted: August 6th, 2008, 6:55 pm
by spradlig
I've got over a hundred pages on wiki (http://wikis.ControlTheoryPro.com) and I'm making more every week. I don't want to update the channel ID section of code for every article I've written or ever will. So I'm thinking of creating a channel ID for each category and trying to track my revenue through the category.

Do I need to assign a URL to each channel with Google before using the channel ID in your code?

Alos, if I were to assign CH01 to a specific category (by assigning the category url to CH01 in your php code), would every page where I included <google>CH01</google> be assigned to that category page?

Re: Adsense Channel ID's

Posted: August 6th, 2008, 7:08 pm
by Paul
I'm not sure about that, but I don't think it works that way. If you want to use category, I think you need to modify the extension to read the category, then display different channel...

Re: Adsense Channel ID's

Posted: October 28th, 2008, 2:59 pm
by boomshot
Hi Paul,
I am wondering how you got the adsense code in the main_page.jpg area?

thx in advance
-t