Ads on MediaWiki

We discuss how to run and deliver ads to a MediaWiki site, whether ads are good or bad, how to choose the right ad network, and what requirements may apply to placing and formatting ads on a wiki page.

...
WikiTeq
Share:
Image of ads on MediaWiki

Pros and Cons of Ads on a Wiki

Many of us likely view website advertising merely as a straightforward means of generating revenue. However, it could be a matter of viewpoint. Below are some arguments supporting and opposing advertising:

Pros:

  • Revenue generation: Advertising can be a source of revenue for websites, which can help to cover the cost of running and maintaining the site.
  • Targeted advertising: With targeted advertising, ads can be shown to users based on their interests and behavior, making them more likely to be relevant and useful.

Cons:

  • Ad fatigue: Excessive or intrusive advertisements can frustrate users, resulting in a poor user experience and possibly decreasing the number of visitors who return. 
  • Misleading or inappropriate ads: If the ads on a site are misleading, inappropriate, or offensive, they can damage the reputation of the site and reduce user trust.

The truth is that, in most cases, MediaWiki users come to the wiki for purposes quite different from getting ads. On the other hand, depending on the subject matter of the wiki, targeted and content-relevant advertising can help readers move to a purchase after getting the necessary information about the product (character, place, lifestyle, etc.) from the wiki article.

You should be aware that many users use ad-blocking software to avoid seeing ads, which can reduce the effectiveness of advertising on a site. For example, the Adblock Plus extension for Google Chrome has over 10 million users, and there are a lot more similar extensions for all major browsers.

Thus, in general, the decision to advertise on a MediaWiki site will depend on the goals of the site owner and their willingness to balance revenue potential with user experience.

Choosing and Advertising Network

Here is a basic workflow on how to choose the right ad network and ad format for your MediaWiki site:

  • Determine goals: Before placing ads on my MediaWiki site, determine your goals. Do you want to generate revenue, promote products or services, or increase brand awareness?
  • Research ad networks: You would research different ad networks to find the one that aligns with your goals and niche. You would consider factors such as revenue potential, ad format, and payment terms.
  • Choose an ad network: Once you've researched different ad networks, you will choose the one that offers the best fit for your goals and niche.

There are several criteria to consider when choosing an ad network for your MediaWiki site. Here are some tips to help you make an informed decision:

  • Niche and audience: Consider the niche and audience of your MediaWiki site. Some advertising networks specialize in specific niches, while others have a broader reach. Look for an advertising network that has a good match with your site's niche and audience.
  • Revenue potential: Look for an advertising network that offers competitive revenue-sharing models. Consider the average cost per click (CPC) or cost per thousand impressions (CPM) rates offered by the network and compare them to other networks in your niche.
  • Ad format and customization: Consider the ad formats offered by the advertising network and how customizable they are. Look for networks that offer a variety of ad formats, such as display ads, text ads, and video ads, and allow you to customize their appearance to fit with the look and feel of your MediaWiki site.
  • Payment terms: Look for an advertising network that offers flexible payment terms and allows you to choose from a variety of payment methods. Consider factors such as minimum payout thresholds, payment frequency, and payment options (e.g., PayPal, bank transfer, etc.).
  • Support and resources: Look for an advertising network that offers excellent customer support and resources such as tutorials, guides, and webinars. This will help you to optimize your ad placement and improve your revenue potential.
  • Reputation and trustworthiness: Research the advertising network's reputation and trustworthiness by reading reviews and feedback from other publishers. Look for networks that have a good track record of paying on time and providing reliable service.

With these criteria in mind, you can choose the ad network that suits your goals and offers the best revenue potential for your MediaWiki site.

Which Advertising Network is Best for MediaWiki?

It's difficult to provide a comprehensive overview of the niche and audience of each of the biggest advertising networks since they often have a broad reach and cater to various niches, and offer a variety of ad formats, including display ads, text ads, native ads, etc. However, here's a brief overview:

  • Google AdSense: Google AdSense is one of the most popular advertising networks, and it caters to a wide range of niches and audiences.
  • Amazon Associates: Amazon Associates is an advertising network that caters to websites and blogs that promote products sold on Amazon. It pays publishers a commission for each sale made through their affiliate links.
  • Media.net: Media.net is an advertising network that specializes in contextual advertising, which means that it displays ads based on the content of the page. It caters to a variety of niches, including technology, health, and finance.
  • AdThrive: AdThrive is an advertising network that caters to websites that have high traffic and engagement rates.
  • Ezoic: Ezoic is an advertising network that uses artificial intelligence to optimize ad placement and revenue.

It's worth noting that these advertising networks are constantly evolving and expanding their reach and polishing targeting algorithms to show ads to users based on their interests and behavior. It's important to research each network and determine which one aligns with your MediaWiki site's niche and audience.

If no network has convinced you, or if monetization is not your main goal, there is an option to run self-advertising. In this case, you are in charge of selling your advertising services by placing and rotating ads directly on your wiki.

How to Place Ads in MediaWiki

Once you've decided on an ad network, you must sign up for an account and follow the steps to get approved. Once approved, you will generate an advertising code for your MediaWiki site. This usually includes choosing the format and size of the ad. 

The tools may vary across networks, but the result will be the same: an embed code to serve ads with the selected parameters.

Should I use an Extension for Ads?

There are a number of extensions available for MediaWiki, but most are either unmaintained or only support a limited number of Mediawiki skins or ad sources. The four extensions that are “stable” as of April 2023 and support at least one of Google AdSense and self-hosted ads are compared in the table below.

 Table 1. Stable ad extensions for MediaWiki as of April 2023. All these extensions are well documented on their respective pages on MediaWiki.org
ExtensionGoogle AdSenseSelf-hosted adsNumber of ad banner locations
Google AdSenseYesNo1
ShoutWiki AdsYesNo1 or more
WikidataPageBannerNoYes1
WimaAdvertisingYesYes1-4

Either way, using extensions can be very restrictive, pushing you towards an ad network or skin choice. Apart from this, extensions suffer from the common issues with the MediaWiki extensions: they can become poorly maintained, outdated or obsolete. The placement of your ads into the skin elements may require some coding, sometimes complex.

MediaWiki Ads Code Embedding

Placing advertisements can be challenging to users who do not have an experienced understanding of MediaWiki. Some of the challenges may include:

  • Needing to find a way of getting the advertisement on every page of the wiki – adding the code manually or with a template on each page would not be very effective.
  • Security considerations: Many HTML tags and JavaScript cannot be added to pages, preventing the code from being pasted into single pages or the site notice.
  • Keeping the code in a proper place: Someone with knowledge of MediaWiki HTML couldadd a banner to the relevant skin PHP file, but this would be destroyed during every upgrade. It may also be difficult for someone to know where to place the code.

Therefore we will fill the gap and explain the ads delivery at the lower level, focusing on network ads embedding into the editable areas of your MediaWiki using system messages and plain HTML / JavaScript provided in the generated code.

MediaWiki System Messages

A system message is a snippet of plain text (), wikitext, CSS, or JavaScript that can be used to customize the behavior of MediaWiki and its appearance for each language and locale. For example, you can see the codenames of all system messages defining the interface elements by adding uselang=qqx parameter to the URL:

The uselang parameter to page URL

You can see the system message codenames in round brackets. There is a page in the MediaWiki namespace corresponding to each system message. For example, to edit the search bar placeholder, you are supposed to edit MediaWiki:searchsuggest-search page:

System message page

Luckily, the whole MediaWiki namespace editing requires special editinterface permission: it makes it a safe place for embedding your ad code.

PageNotice

As we don’t want to break any existing system message, we’ll use the extension PageNotice that creates four areas editable via specific system messages:

  • top notice for page XXX goes in MediaWiki:top-notice-XXX
  • bottom notice for page XXX goes in MediaWiki:bottom-notice-XXX
  • top notice for pages in namespace NNN goes in MediaWiki:top-notice-ns-NNN (where NNN is the numeric namespace ID)
  • bottom notice for pages in namespace NNN goes in MediaWiki:bottom-notice-ns-NNN (where NNN is the numeric namespace ID)

It means that you will be potentially able to display ads separately by namespaces or even bring specific ads to given pages.

MediaWiki Widgets

The generated ad network code is usually a mix of arbitrary HTML, CSS, and Javascript. Since MediaWiki allows only certain HTML tags, we’ll use a separate namespace offered by the Widgets extension. The Widget namespace is good for embedded ads code hosting as it is editable only under a special user right (editwidgets).

There is a collection of widgets on MediaWikiWidgets.org, including the AdSense widget by Ike Hecht.

Make sure that you have Widgets and PageNotice installed, your user account has got the editinterface and editwidgets permissions and proceed to building your ads mechanics.

Widget AdSense example

Note: Registration and login with a valid email are required to access the widget code and examples.

Step 1. Copy the AdSense widget code and save it on the page Widget:AdSense of your wiki.

Step 2. In Google AdSense, click "Get code". Copy that code. It will look similar to this:

Step 3. To display ads in the top notice area for the main namespace, place the following code on the page MediaWiki:Top-notice-ns-0, passing the values taken from the Google AdSense code:

{{#widget:AdSense
|client=ca-pub-0000000000000000
|slot=00000000000
|width=160
|height=600
}}

Save the page. You are done!

More examples and hints you can find on the widget page.

Post-install

Once you have completed all the steps:

  • Test your site to ensure that the ads are displaying correctly.
  • Use MediaWiki site JS and CSS to position and style your ads container.
  • Start monitoring your ad network account to track your earnings and optimize your ad placement and targeting to improve your revenue potential.

If you opted to continue on your own please make sure you are familiar with the “Ads placing policies” by Google. You will learn what practice and approaches are considered bad:

  • Encouraging accidental clicks
  • Unnatural attention to ads
  • Placing ads under a misleading heading
  • Aligning images with ads
  • Formatting content to mimic ads
  • Offering compensation

For a professional looking integration of ads into your current skin and maximizing your revenue potential, do not hesitate contacting professionals. We are here to answer any of your MediaWiki questions and professional MediaWiki help, training, maintenance, and hosting services. You can find additional MediaWiki related articles on our blog.

Latest Stories

Here’s what we've been up to recently.


Get our stories delivered

From us to your inbox weekly.