Paul Gu | Blog

sharing is caring

Google AdSense extension for MediaWiki released.

I just released my new MediaWiki extension called Google AdSense.

Google AdSense is the program that can give you advertising revenue from each page on your website—with a minimal investment in time and no additional resources.

This extension will allow you to add all types of Google AdSense as you need. It can display AdSense for content with specific channel, AdSense for search, and Referrals. Also you can put AdSense anywhere in your content page.

Detail information can be found at paulgu.com , under Projects. You are very welcome to download.

Next Post

Previous Post

39 Comments

  1. Aj January 10, 2007

    Could you give more detailed instructions, and information about this media wiki extension please.

    Thanks in advance, Aj

  2. Paul January 10, 2007 — Post Author

    How to install it?

    Here are the steps that may work for you:

    1) Download the extension file from my web site, and unzip it into your “extensions” directory. It should create a “GoogleAdSense” folder with a files named GoogleAdSense.php.
    2) Add this to the end of LocalSettings.php: include_once(“extensions/GoogleAdSense/GoogleAdSense.php”);

    How to use it?

    Add google tag in anywhere to your wiki page.

    I had updated the extension page, you could find more details about how to customize and install it.

  3. eric January 26, 2007

    I’m wondering how this works on a public wiki where the content can be edited by any registered user.

    Is there any way to have adsense code added to pages automatically (e.g. from within the template)?

    I’m really new to wiki (but not web publishing).

    Thanks for any help.

    Eric

  4. Paul Gu January 26, 2007 — Post Author

    This can be done by following ways:

    • 1. Protect the page that has AdSense
    • 2. Only allow trusted users to edit the page that has the AdSense
    • 3. Like you mentioned, you could add it into templates and it will be loaded automatically. You need to know a little bit of programming. You can check my MediaWiki skin _ycgu_max_ 1.10, which it contains AdSense.
  5. Markus February 2, 2007

    Paul,
    many thanks for your great work!
    We now have based our site on Mediawiki and your Skin. We also use your Adsense-Extension – a fine piece of work! Check http://www.bankrz.com and look out for random pages – it really allows to input Adsense into all articles!
    Many thanks

  6. Paul Gu February 2, 2007 — Post Author

    You are very welcome! Your site looks really nice, Good modification!

  7. Leonardo February 6, 2007

    Hi, i ceated Google Adsense accounto today, i received this code:
    AdSense para conteúdo: ca-pub-6843694953832787
    AdSense para pesquisas: partner-pub-6843694953832787
    Referências: ca-ref-pub-6843694953832787

    But in you installation tutorial of your extension say to change the channel id. When i open the php file what i need to insert and where.
    Is this code above channel id?
    i really don’t understand, please help me

  8. Paul Gu February 6, 2007 — Post Author

    There are two functions: gAdSenseforContent() and gAdSenseforReferrals(). You need to change “google_ad_client” to your id above, which is pub-6843694953832787.

    The channel id in my instruction is Google AdSense for Content channels, you need to create your own as well.

  9. Leonardo February 7, 2007

    And how to create my own channel id? what i need to do?

  10. Paul Gu February 7, 2007 — Post Author

    In Google AdSense for Content, choose creating your own channel, and it will give you the channel id.

  11. Arno February 21, 2007

    Is it possible to extend the functionality so that the google tags can be placed in a table to align or to float on the right hand side?
    This does not currently work.
    example below

    {| border=”1px” class=”wikitable” style=”border:1px solid #AAA; background:#F9F9F9; width:200px; margin: 0 0 1em 1em; padding:.2em; text-align:center; float: right;”
    |-
    | WIKI
    |}

  12. Paul Gu February 21, 2007 — Post Author

    You could put two tags outside of the Google Adsense, limit inside tag width as the Ad’s width, and make outside tag width as 100%. Now you can define Adsense position in outside tag.

  13. SactoEric February 25, 2007

    I’m unclear about what to put between the tags… I see some people have something different than your examples. I also see that adsense site search is possible, but currently the only one I have working is the web search. And, how do I add the different size adsense for content blocks?
    Thanks! 🙂

  14. Paul Gu February 25, 2007 — Post Author

    The size is pretty much limited by Google AdSense; it has a few options and each has different size. You also could put a few AdSenses together to have a big one.

    In my extension, the size is come from one of the Google AdSense, you need to change that according the size from Google AdSense.

  15. SactoEric February 25, 2007

    A leaderboard is fine for me right now, but the problem is that nothing shows up. Your example says to use WIKI …what does that “WIKI” represent? Another person above has something different between the tags. And, of course, if I put nothing between the tags, I get the search box, but it’s the web search. I was also wondering how to display the site search rather than just the web search.

  16. SactoEric February 25, 2007

    (the “google” tags don’t show up in my replies)

  17. Paul Gu February 25, 2007 — Post Author

    The “WIKI” doesn’t mean anything, just an ID that tells extension to display the Google Ads, you can use whatever word you like, it doesn’t matter. If you want to display the site search as well, the function is included, you need to open the php file:

    if($input == “AUTO”) {
    $channel = “2591336448”;
    $output = gAdSenseforContent468( $channel );
    } else if($input == “JOB”) {
    $channel = “2231050768”;
    $output = gAdSenseforContent468( $channel );
    } else if($input == “WIKI”) {
    $channel = “4937260289”;
    $output = gAdSenseforContent468( $channel );
    } else if($input == “REF”) {
    $channel = “4937260289”;
    $output = gAdSenseforReferrals( $channel );
    } else {
    $output = $outputSearch;
    }

    change the last “$output = $outputSearch;” to ” $output = $outputSearch2;”, also you need to change the “value=\”pub-5682696638988997\” to your id and search site to yours.

  18. SactoEric February 25, 2007

    Okay, this is getting beyond frustrating… I had already changed the channels and “pub” values to my own. I just changed the output to outputSearch2. Nothing has changed. The search that displays (w/ nothing between the google tags) is still the web search, even after a forced refresh. The leaderboard still doesn’t show up using WIKI or anything else between the google tags.

    I even copied the code you have above and replaced the original (then inserted my channel IDs). The original had “gAdSenseforContent” rather than the “gAdSenseforContent468” your example above shows. Neither work.

    Any idea why? btw, I’m using 1.9.x

  19. Paul Gu February 25, 2007 — Post Author

    After you changed the extension, you need to edit the MediaWiki page that contains the extension, and do Edit and Save if you don’t change anything in order to make the page display the updated extension. You need to do the same thing to all pages that are using this extension.

    I don’t know why, it might be caching or something else, but the above way works for me.

  20. SactoEric February 25, 2007

    That’s weird… I did that for a couple pages and now I see the site search; however, the adsense for content isn’t showing up – I now have two search boxes, one pre-filled w/ WIKI. I think that’s a violation… Unless Google has changed that recently, you aren’t allowed to pre-fill search boxes.

  21. Paul Gu February 25, 2007 — Post Author

    It’s not Google, you must have “WIKI” inside your google tag, remove that if you don’t want to pre-fill any thing.

  22. SactoEric February 25, 2007

    According to your instructions at the following URL you put WIKI between the google tags to show the leaderboard. http://paulgu.com/wiki/Mediawiki_Extensions

    If I don’t have that between the google tags, then it shows the search box, which I already have. How about this… What exactly do I need to have to show the leaderboard? So far nothing else has worked.

  23. Paul Gu February 25, 2007 — Post Author

    According the key word that you defined in extension like “WIKI”. That’s why if you don’t know php programming, please leave as it is to make it work as I released.

  24. SactoEric February 25, 2007

    It didn’t work as you released.

  25. SactoEric February 25, 2007

    All I can hope is that it’s set to show the search bar when there aren’t any ads to display and the adsense bot hasn’t crawled my site yet. Is there a simple way to change it to to show either a solid color or PSAs when there aren’t ads? Why it’s set up to show a prefilled search box is beyond me. That’s just asking for trouble…

    Also, I have a question here about the logo here:
    http://blog.paulgu.com/2007/01/15/my-new-mediawiki-skin-gumax-30-is-released/#comment-217

  26. SactoEric February 27, 2007

    Thanks for the help Paul!
    I finally figured out that it was a problem w/ using “center” tags rather than “div align=center” …the “center” tags were adding paragraph breaks inside the javascript for the adsense for content ads. It didn’t seem to affect the referrals or search boxes. It looks like everything is working fine & just in time too since I started linking to the new site today 🙂

  27. Paul Gu February 27, 2007 — Post Author

    Cool, I’m so glad that is working now.

  28. Moopf March 10, 2007

    i get this Error, when i inclucde the line

    include_once(‘extensions/GoogleAdSense/GoogleAdSense.php’);

    anywhere in localsettings.php (path is correct!)

    I’m using Apache and WinXP, Wiki is running perfect (without this Googlead)

    Warning: Division by zero in N:\Path\To\Server\LocalSettings.php on line 123

    Warning: Division by zero in N:\Path\To\Server\LocalSettings.php on line 123

    Warning: include_once(php?) [function.include-once]: failed to open stream: No such file or directory in N:\Path\To\Server\LocalSettings.php on line 123

    Warning: include_once() [function.include]: Failed opening ‘php?’ for inclusion (include_path=’.; N:\Path\To\Server; N:\Path\To\Server/includes; N:\Path\To\Server/languages’) in N:\Path\To\Server\LocalSettings.php on line 123

    Can you help me?

    Tahnks Moopf

  29. Jake Morgan April 29, 2007

    I’m having difficulty adding my adsense code to my wiki – I’ve tried various different techniques and none of them appear to work – your code seemed the easiest solution, but I’m really struggling with it so far!

    I’ve followed your instructions exactly, and added the following to my LocalSettings.php:

    —————————–
    $wgRightsPage = “”; # Set to the title of a wiki page that describes your license/copyright
    $wgRightsUrl = “”;
    $wgRightsText = “”;
    $wgRightsIcon = “”;
    # $wgRightsCode = “”; # Not yet used

    $wgDiff3 = “”;

    ?>

    include_once(‘extensions/GoogleAdSense/GoogleAdSense.php’);

    —————————–

    This to me is how you stated it should be – the last line of the file LocalSettings.php. I have tried it in various other places and get different errors, but the current error is as follows:

    include_once(‘extensions/GoogleAdSense/GoogleAdSense.php’);

    (This shows right at the top left of my wiki).

    I’m not sure where to take it from here as I’ve tried pretty much everything (including all different alternatives online!)

    Any help or advice would be greatly appreciated!

    Jake.

  30. Jake Morgan April 29, 2007

    Just a further comment,

    I added the include section 1 line above the end (before the ?>) and I got this on my wiki:

    Warning: Division by zero in C:\wamp\www\wikimenus\LocalSettings.php on line 112

    Warning: Division by zero in C:\wamp\www\wikimenus\LocalSettings.php on line 112

    Warning: include_once(php) [function.include-once]: failed to open stream: No such file or directory in C:\wamp\www\wikimenus\LocalSettings.php on line 112

    Warning: include_once() [function.include]: Failed opening ‘php’ for inclusion (include_path=’.; C:\wamp\www\wikimenus; C:\wamp\www\wikimenus/includes; C:\wamp\www\wikimenus/languages’) in C:\wamp\www\wikimenus\LocalSettings.php on line 112

  31. Paul Gu April 29, 2007 — Post Author

    Hi Jake,

    It looks like the path is not correct under your web server.

  32. Jake Morgan April 29, 2007

    Hi Paul –

    I’ve just got it working!!!

    All I need to do now is edit the GoogleAdsense extension php itself, thanks for making an excellent addon –

    My solution was:

    instead of: include_once(”extensions/GoogleAdSense/GoogleAdSense.php”);

    it is simply: include(”extensions/GoogleAdSense/GoogleAdSense.php”);

    I’m not sure why it works but it does 🙂

  33. Paul Gu April 29, 2007 — Post Author

    Great!

  34. Ron Sheely May 7, 2007

    Hi Paul,

    I am evaluating AdSense extensions for a new MediaWiki site. The MediaWiki site centiare.com appears to use a AdSense extension different than yours. What comments can you provide that might help me make my decision? The positive feedback I see on this blog is certainly leaning me in your direction. One of my concerns is future MediWiki compatibility. Some extensions have broken my other MediaWiki sites after routine upgrades.

    Thanks in advance,

    Ron

  35. Paul Gu May 7, 2007 — Post Author

    Hi Ron,

    I’m not sure what they are using, my AdSense is just applying types of Google AdSense into Wiki, like embedding the Google AdSense code in your web site, it should always work. It works as Google described.

    I have upgrade my Wiki from 1.8 to 1.9, my AdSense extension works great without changing anything.

  36. Ron Sheely May 8, 2007

    Thanks Paul for the timely response. I’ll try it out. I tend to use the MediaWiki trunk, though I always do a trial update before I release my production version. I’ll be sure to let you know how it goes.

    BTW, what kind of credits do you enjoy seeing on MediaWiki sites that use your extensions?

    -Ron

  37. Paul Gu May 8, 2007 — Post Author

    You are welcome.

    I will release a new version to make it easy to customize, such as channel id and client id.

    The type of credits is up to you according to your web site. Anything convenient for you would be great.

    Thanks,
    Paul

  38. Ron Sheely May 8, 2007

    Hi Paul,

    It took me about five minutes to install your AdSense extension, and run a quick test. I’ll continue to test the next couple days.

    Thanks for your nice work.

    -Ron

Leave a Reply

© 2024 Paul Gu | Blog

Theme by Anders Norén