How to target  ads to multiple languages in TranslatePress

Using the free TranslatePress plugin, you can set up a multilingual website in WordPress to internationalize your content and grow your audience. If you are monetizing such a website with ads, delivering those explicitly for the specific user’s language makes sense for several reasons. 

Not only will you be able to deliver relevant content to your users in their own language. But you can also improve your conversion rates by redirecting visitors to targeted pages in their language. This enhances the overall user experience and makes them more likely to take the desired action.

In this tutorial, you’ll learn how to use Advanced Ads to deliver ads based on the TranslatePress language of your content.

Targeting ads by language-specific URL parameter

If you have enabled subdirectories for the default language, then using Advanced Ads Pro‘s URL parameter display condition is the most convenient way to target language-specific ads. That’s because, in this setting, TranslatePress inserts a country code for each language in the URL slugs, including one for the default language.

TranslatePress subdirectly settings

Such a URL slug could look like this for the English version: https://wpadvancedads.com/en/advanced-ads-pro/. In contrast, the German equivalent might look like this: https://wpadvancedads.com/de/advanced-ads-pro/.

If you want to show ads in English on your English language posts, you will target ads to pages with URL slugs that contain “/en/”.

But if you want to disable a subdirectory for the default language, you can also use the URL parameter condition to target this particular content. Invert the condition setting to show the English ads only on pages that do not contain “/de/“.

You can also target ads on archive pages, such as category pages, by using URL parameters. Just make sure their URL slugs contain the specific country code.

URL parameter condition to target TranslatePress
Excluding ads from German and French content with the help of the URL parameters display condition

Advanced Ads Pro’s time-saving feature of adding conditions to entire placements is extremely convenient in this situation. You can create a custom placement for specific languages, meaning you don’t have to set individual conditions for every ad unit.

Targeting ads using the TranslatePress shortcodes

If you don’t want to use the URL parameter condition, you can use TranslatePress’ shortcodes to show or hide content depending on the chosen language. Here’s how you would set this up:

  1. Create an ad group for each language you have added in TranslatePress and for which you want to show specific ads.
  2. Add your language-specific ads to the corresponding ad group.
Ad groups that contain language-specific ads
  1. Create a new ad unit with the “Plain text and code” ad type. You will use this ad unit solely in order to show the appropriate ad group depending on the language of the content.
  2. Insert the TranslatePress shortcodes, which recognize the selected language and output the enclosed contained content in case of a positive match.

The shortcode to show a specific ad group only in content assigned to an English (US) translation looks like this:

[trp_language language="en_US"] [/trp_language]
Code language: JSON / JSON with Comments (json)
  1. Put the shortcodes of your ad groups between the TranslatePress shortcodes. You can retrieve these shortcodes by clicking the “Show usage” link under the ad group’s name.

Example of language-specific ads and TranslatePress shortcodes

In the following example, you can see what controlling the injection of an English and a German ad group to the related content looks like.

TranslatePress shortcodes
How to use TranslatePress shortcodes to target language-specific ads

You can now assign this ad unit that you will use to control the language-specific ad output to a placement and automatically insert it into the content of your website. If a user now calls up a page that TranslatePress recognizes as English (US), WordPress will execute this shortcode and, lastly, will include the ad group.

Obtain the code as well as the URL parameter of each language under Dashboard > Settings > TranslatePress > General.

Of course, adding multiple ads to this group is possible so that different ads may rotate at this position.

TranslatePress language codes and slugs

And that’s all you need to know to deliver your ads tailored to the served  content’s TranslatePress language. I hope your advertisements’ significantly higher click-through rates will reflect this improved targeting.

Joachim

Joachim started marketing his first local news website in 2009. Shortly after, he successfully monetized his travel blogs about Morocco. He is an expert in affiliate marketing in the tourism and travel industry. When he's not writing tutorials for Advanced Ads or supporting other users, he prefers staying in Marrakech or at the Baltic Sea.

Make it better

Increase your ad management skills without spending more time.
Join over 150,000 publishers and AdOpts increasing their ad revenue.