Demystifying Betting Myths
Statistics are the language of betting; learn to speak fluently, and the market will reveal its secrets.

Experience the future of sports betting education at our new store – visit Soccerwidow's new store!

Multilingual Ad Targeting & Positioning in WordPress

C’est facile, n’est-ce pas?

This blog is not only a bilingual German and English site, but most of the adverts on it also fit the article topics and display in the correct language. For example, if you press F5 and reload a page different adverts are displayed.

There are plenty of ‘Ad Targeting’ articles in the Net but there seems to be very little regarding ad targeting and positioning in multilingual Web sites, so we used our own initiative to work out the following solution. Once figured out it’s actually quite simple and can be used for any kind of ad targeting, not only for multilingual sites.

This blog is built around the WordPress ‘Forester’ theme and for management of the multilingual content we use the WordPress plugin WPML Multilingual CMS. The current combination of WordPress 3.3.2., Forester theme and WPML 2.4.3. seem to work seamlessly and harmoniously together.

For language separation, we use ‘domain name one’ ( for our English language content and ‘domain name two’ ( as our German language version.

For advert administration we use AdRotate. This plugin is free of charge up to 5,000 page views a day, which is probably plenty for most Web sites. As soon as this threshold is crossed, AdRotate asks for a small monthly fee, which is entirely fair and acceptable considering the amount of time and effort that must go into producing such plugins.

Organising your Adverts in AdRotate

  1. Advert Database

    Simply install the plugin in WordPress and begin uploading your adverts placing them into the database under ‘Manage Ads’.

    With numerous ads of different shapes and sizes a clear and self-explanatory heading is of vital importance in order not to get confused and overwhelmed if your database grows to hundreds of adverts over time. Our headings are structured as follows:

    Name of advertising company – size of advert – description of advert – language – account administration status

    Example: Betfair (300×250) – Direct Link to Sportsbook – English – Direct partner

    The account administration status is important since you will no doubt have a mixture of direct affiliate agreements with some companies and others via agencies as the administration of affiliate programs is often outsourced. However, you will perhaps never find an agency offering all the companies you would like to use on your site, especially if you are choosy and prefer to handpick adverts rather than taking any offer which comes along. If you prefer to be selective and in control, your portfolio may include as many as 10 different agents plus 30 or more individual companies, and we stress once again that good title management is essential to avoid a huge muddle in your dashboard.

  2. Advert Groups

    Adrotate allows you to organise a set of adverts to randomly rotate wherever you place the ad group on the page. If you have, say, 10 different 300×250 ads in English, which you would like to display randomly on the English version of your Web site then organise them in a group as follows:

    Example: Home Page (300×250) – English – General

    Into this field, drop all of the ads with the same size (i.e. 300×250) that you wish to have displayed randomly on your home page. If you are running a multilingual site, you will need to organise your adverts into groups not only by size and content, but also by language.

    We have the following three groups:

    Sidebar (120×600), Home Page (300×250) and Post (468×60), in both German and English, making in this case a total of six groups.

    In addition, we have things such as Sidebar Amazon and Sidebar Tickets, again separated into English and German, which rotate both company’s current offers and displays different products on different pages.

    A logical structure is so important for the advert groups as this is probably the most significant advantage to have when thinking about ad management and targeting. It took us a while before we came up with a simple and logical structure for this Web site.

  3. Advert Blocks

    If you wish to display more than one advert in the same place then you can put the groups into blocks. Groups only display one advert at a time, but blocks can combine 2, 3, 4 or more adverts and display them together.

    For example, we use blocks for 468×60 adverts placed in the posts. The 300×250 adverts and the sidebars are managed using groups, but this is an individual choice. Both functions work well and painlessly with AdRotate.

Having organised your adverts into groups, integrating them into the Web page is next.

PHP code for inserting Adrotate rotating adverts into your WordPress blog

The code, once worked out, is actually quite simple. Just copy and paste the following wherever you would like your ads to display:

<!-- Adrotate multilingual -->
if ($_SERVER['SERVER_NAME'] == '') {
	echo adrotate_group(4);
} else {
	echo adrotate_group(3);

The code above means:

if ($_SERVER[‘SERVER_NAME’] queries the domain name from the server and if it’s TRUE then ad group number 4 will rotate (i.e. our adverts 300×250 in English). If the query is FALSE then adverts in group 3 are displayed instead, which in our case are the equivalent German language adverts.

This is really all you need to do to display your adverts by language.

The programming becomes a little more advanced if you need to display certain adverts in certain articles but not in others. For example, this article is about WordPress and Ad Targeting and therefore our preference might be to display adverts from IT companies but not betting sites.

To achieve this, a new AdRotate group needs to be created containing only those 300×250 adverts relevant to this article. After this group is set, we expand the if – elseif – else code as follows:

<!-- Adrotate -->
<div style="text-align: center;">
if(strpos($_SERVER['REQUEST_URI'],'NAME OF THE ARTICLE in English’) !== false) {
echo adrotate_group(XX);
} elseif($_SERVER['SERVER_NAME'] == '')
echo adrotate_group(4);
} elseif(strpos($_SERVER['REQUEST_URI'], 'NAME OF THE ARTICLE in Deutsch') !== false) {
echo adrotate_group(YY);
} else {
echo adrotate_group(3);
} ?>

Above code “translated”:

The code checks the URL if it matches the string of this particular post in English. If correct, designated by (!), it then rotates adverts in group ‘XX’ (the name we gave to the ad set specifically for this post). However, Soccerwidow has many more posts and pages, not just this one. Therefore, if the code doesn’t identify the page as being the WordPress and Ad Targeting post, it proceeds to step two (elseif) and checks whether the URL is If it is, then group 4 rotates instead (i.e. the general adverts in English).

If the code doesn’t identify the page as the WordPress and Ad Targeting post in English, or identify it as being any other post in English (, its next step is to check whether the page is the German version of the WordPress and Ad Targeting post (which uses the group number ‘YY’). If this is not a match, it will eventually display group 3 instead (i.e. the general adverts in German).

The code becomes longer and more complicated as greater numbers of individual posts are included. You can even include ‘tags’ in your code;

if (has_tag( array( 'courses', 'tutorials' )))

or target your adverts using categories. You can effectively target your selections on whatever aspect you like, not just languages. This is a really powerful tool for perfect positioning of your ads. However, you will need to judge for yourself how much ‘individualizing’ is actually necessary for your site and whether the whole effort is in fact worthwhile?

PHP Code in Sidebars

Inserting PHP code into sidebars is not normally possible. Sidebars work with widgets and the only suitable widget is the text widget, which only permits HTML and doesn’t work with PHP.

Therefore, you will need a PHP widget plugin for WordPress, which functions exactly like the textbox widget but allows you to execute PHP in the sidebar (WP PHP Widget). After you’ve got this plugin, simply go into the widget administration and pull the PHP widget into the desired sidebar to the required place and insert the appropriate PHP code (see above). You will of course have to select the AdRotate group with the appropriate format for your sidebar ads.

Adrotate Banners in Posts

The code for inserting adverts into posts is as follows:-

<div style="float:left;margin:8px;">[adrotate banner="AAA"]</div>

Place the code for your Adrotate adverts in the article where you would like to have the advert displayed. This can be a banner (single advert), or an advert group or block. Simply copy and paste the appropriate code from Adrotate.

This <div style=”float:left;margin:8px;”>The Adrotate CODE here</div> instruction gets your text floating around the ad (if you want it to). You can choose to float it on the left or the right or however you wish it to appear.

Alternatively place your advert in the post and just centre it if you wish with the following instruction:

<center>The Adrotate CODE here</center>

So, that’s it – C’est facile, n’est-ce pas? – It’s easy, isn’t it?

Happy smiling black woman with thumbs upImage: Samuel Borges Photography (Shutterstock)


You have now inserted targeted ads, showing your required content in the appropriate language!

At this stage, we urge the utmost caution especially to those of you who are not particularly experienced or confident with PHP programming.

A wrongly entered PHP code (even if just one symbol is omitted or entered in a wrong place) can lead to the crashing of your entire web site.

Therefore, before you start altering PHP code in your website, please first ensure you have access to your FTP server (and also know how to work it!). This will be vital in accessing files to correct and/or delete any wrong coding. An incorrect PHP code may also lead to WordPress breaking down and therefore disallowing any further administration. In the majority of cases, incorrect coding can only be restored using FTP.

We wish you success with placing, rotating and targeting (multilingual) adverts in your blog. If this article has helped you in some way, we would be very happy if one or two of you investigate some of the adverts on our blog, as this will help us to generate money with this site and continue offering free content.

Last Update: 4 June 2012

Categories:Website Monetising Wordpress Tips

One Response to “Multilingual Ad Targeting & Positioning in WordPress”

  1. 31 January 2015 at 12:00 pm #

    This is a quite very good tips especially to individuals new to blogosphere, transient and accurate details? Many thanks for sharing this a single. A must examine report. 😉

Leave a Reply / Comment

Notify me of followup comments via e-mail. You can also subscribe without commenting.