Help Center

Integration into site pages

Integrating an advertising block into a site

To directly integrate ad units into website pages:

  1. Copy the JavaScript code from the ad unit settings in your account.
  2. Paste the code into the website in the place of the HTML page where the ad unit should be displayed.
  3. The same unit (one slot_id) can be placed multiple times on a page without changing the slot_id.

Example of basic code

<script async src="https://ad.mail.ru/static/ads-async.js"></script>
<ins 
  class="mrg-tag"
  style="display:block;width:100%;text-decoration:none;"
  data-ad-client="ad-1111111"
  data-ad-slot="1111111">
</ins>
<script>
  (MRGtag = window.MRGtag || []).push({});
</script>

data-ad-slot — this is the slot_id of the ad unit (can be found in the settings)

Examples for specific formats

To integrate a block for a specific format, you need to add the dl parameter as the data-ad_query attribute inside the <ins> tag with the value URLENCODE(url).

The dl parameter tells the system where the ad is shown. Without it, the impression may not be counted, and the traffic may be limited (throttling). It is mandatory for everyone who is not the owner of the site.

URLENCODE(url) is a function (or simply a designation) that means encoding the URL into a format that is safe for transmission in the address bar or in query parameters.

symbolencoded meaning
space%20 or +
::3A
/%2F
?%3F
&%26
=%3D

We support: 240x400, 300x250, 300x300, 300x600, 320x50, 336x280, 970x250. Let's look at the code using the example of 300x250.

300х250

<script async src="https://ad.mail.ru/static/ads-async.js"></script>
<ins class="mrg-tag" 
   style="display:inline-block;width:300px;height:250px"
   data-ad-client="ad-123456" 
   data-ad-slot="123456”
   data-ad_query="dl=https%3A%2F%2Fexample.com"> <!-- URLENCODE(url) --!>
   </ins> 
<script>
   (MRGtag = window.MRGtag || []).push({});
</script>

For the remaining sizes, only the parameters in the style attribute change — width, height.

Adaptive block

<ins class="mrg-tag" data-ad-client="ad-%slot_id%" data-ad-slot="%slot_id%"></ins>

Fullscreen block

<ins class="mrg-tag" data-ad-client="ad-%slot_id%" data-ad-slot="%slot_id%"></ins>

inPage

<ins class="mrg-tag" style="display:block; text-decoration: none;" data-ad-client="ad-%slot_id%" data-ad-slot="%slot_id%"></ins>

Sticky

<ins class="mrg-tag floating" style="display:inline-block; width:320px; height:50px;" data-ad-client="ad-%slot_id%" data-ad-slot="%slot_id%"></ins> 

AMP formats

AMP Medium (300x250)

<amp-ad width="300" height="250" type="mytarget" data-ad-slot="%slot_id%"></amp-ad>

AMP Standard (320x50)

<amp-ad width="320" height="50" type="mytarget" data-ad-slot="%slot_id%"></amp-ad>

AMP Leaderboard (728x90)

<amp-ad width="728" height="90" type="mytarget" data-ad-slot="%slot_id%"></amp-ad>

If you have any questions about installing ad units, please contact support.