Extension:Google AdSense

From MediaWiki.org
(Redirected from Extension:Google AdSense 2)
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
Google AdSense

Release status:Extension status unmaintained

Extensions-GoogleAdSense2.png
ImplementationTemplate:Extension#type Skin
DescriptionTemplate:Extension#description Allows to add Google AdSense to the sidebar
Author(s)Template:Extension#username Siebrand Mazeland (Siebrandtalk)
Latest versionTemplate:Extension#version 2.2 (2014-03-31)
MediaWikiTemplate:Extension#mediawiki 1.18+
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license MIT License
Download
ParametersTemplate:Extension#parameters
  • $wgGoogleAdSenseClient
  • $wgGoogleAdSenseSlot
  • $wgGoogleAdSenseID
  • $wgGoogleAdSenseWidth
  • $wgGoogleAdSenseHeight
  • $wgGoogleAdSenseSrc
  • $wgGoogleAdSenseAnonOnly
Hooks usedTemplate:Extension#hook
SkinBuildSidebar

Translate the Google AdSense extension if it is available at translatewiki.net

Check usage and version matrix;

[1]The Google AdSense extension allows to easily add Google AdSense advertisements to the sidebar of your wiki. This extension requires an account with Google's AdSense.

Installing[edit]

  • Download and place the file(s) in a directory called GoogleAdSense in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/GoogleAdSense/GoogleAdSense.php";
// Your Publisher ID
$wgGoogleAdSenseClient = 'pub-8330046405419293';
// Your AdSense AD Unit ID
$wgGoogleAdSenseSlot = '1640430293';
// This can be anything you like
$wgGoogleAdSenseID = 'yourwiki-2';
  • Add any of the optional settings below, if your settings deviate from the defaults
// Width of the AdSense box, specified in your AdSense account
$wgGoogleAdSenseWidth = 120;
// Height of the AdSense box, specified in your AdSense account
$wgGoogleAdSenseHeight = 240;
// Source URL of the AdSense script
$wgGoogleAdSenseSrc = "https://pagead2.googlesyndication.com/pagead/show_ads.js";
// Show the AdSense box only for anonymous users
$wgGoogleAdSenseAnonOnly = true;
$wgGoogleAdSenseClient = 'replace this with the client name';
$wgGoogleAdSenseSlot = 'replace this with the slot name';
$wgGoogleAdSenseID = 'replace this with your ID';
  • If you want to add a "Text/image, 200x200" into the Vector skin you will need to shift the left panel over slightly. Add the following to the "MediaWiki:Vector.css" page
#content,
#footer {
    margin-left: 11em;
}
#left-navigation {
    left: 11em;
}
  • The default portlet label ("Advertisements") can be changed to "Sponsored Links" on the "MediaWiki:Googleadsense" page. Please note: no other variations are permitted[2].
  • Remember to disable ad-blocking services such as AdBlock when you want to see if the extension is working!
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

See also[edit]

  • Widget for Google Adsense display within wiki pages (not within the skin)
    • <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> </ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>
    • Placing ads under a misleading header, AdSense Help: Ad placement policies.