Adsense Channel ID's

Use this forum to ask questions about how to do things with my MediaWiki Extensions.
User avatar
squidmarks
Rank 0
Rank 0
Posts: 4
Joined: April 7th, 2008, 7:15 pm

Adsense Channel ID's

Post 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
User avatar
Paul
Development Team Leader
Development Team Leader
Posts: 1132
Joined: October 20th, 2007, 2:23 pm

Re: Adsense Channel ID's

Post by Paul »

IMO the channel thing is for you to track which page is hot. :D
User avatar
squidmarks
Rank 0
Rank 0
Posts: 4
Joined: April 7th, 2008, 7:15 pm

Re: Adsense Channel ID's

Post 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
User avatar
Paul
Development Team Leader
Development Team Leader
Posts: 1132
Joined: October 20th, 2007, 2:23 pm

Re: Adsense Channel ID's

Post 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
User avatar
squidmarks
Rank 0
Rank 0
Posts: 4
Joined: April 7th, 2008, 7:15 pm

Re: Adsense Channel ID's

Post 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
User avatar
squidmarks
Rank 0
Rank 0
Posts: 4
Joined: April 7th, 2008, 7:15 pm

Re: Adsense Channel ID's

Post 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'
);

?>
User avatar
Paul
Development Team Leader
Development Team Leader
Posts: 1132
Joined: October 20th, 2007, 2:23 pm

Re: Adsense Channel ID's

Post by Paul »

Thanks for great work :D .
User avatar
spradlig
Rank 0
Rank 0
Posts: 3
Joined: August 6th, 2008, 6:48 pm
Location: Colorado
Contact:

Re: Adsense Channel ID's

Post 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?
User avatar
Paul
Development Team Leader
Development Team Leader
Posts: 1132
Joined: October 20th, 2007, 2:23 pm

Re: Adsense Channel ID's

Post 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...
User avatar
boomshot
Rank 1
Rank 1
Posts: 5
Joined: August 30th, 2008, 6:22 pm

Re: Adsense Channel ID's

Post by boomshot »

Hi Paul,
I am wondering how you got the adsense code in the main_page.jpg area?

thx in advance
-t
Post Reply