AdSense Ad Code Implementation [Code]

Subown.com

With Subown you can easily implement AdSense into your website and create a multi-screen compatible advertising campaign with great revenue potential in minutes. This guide explains how to implement AdSense ads with Subown.

Your to-do list

This is part 4 of The Ultimate 5-Point Guide To Upgrade Your Website With Subown.

If you haven't already, add the subown.js JavaScript Library to your page's HTML source code. The library is required to render Subown compatible AdSense ads.

Implement AdSense Ads With Subown

Follow these steps to enable AdSense ad units for Subown.

1. Sign into your AdSense account.

2. Create an asynchronous AdSense ad unit, and copy and paste it into the form below:

3. Select if the created ad is a "Text & display ad", "Text ad only", or "Display ad only":

4. Click on GET CODE to create your Subown compatible AdSense ad unit.

[Final code appears here - click 'GET CODE']

Important: Before adding the code to your page, please make sure that your page complies with the AdSense program policies. Do not make any other changes than suggested by Subown. Please note that the AdSense program policies do not permit any alteration to the AdSense code which artificially inflates ad performance or harms advertiser conversion. For more information see Modification of the AdSense ad code - Ad implementation policies | AdSense Help.

Advertisement

Documentation

1. The line

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

included in the asynchronous AdSense ad code, like e.g. (from here)

    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <ins class="adsbygoogle"
        style="display:inline-block;width:300px;height:250px"
        data-ad-client="ca-pub-xxxxxxxxxxxxxxxx"
        data-ad-slot="6440411535"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>

must be removed on each ad unit before you paste the ad code in your page's HTML source code.

Here's why:

The adsbygoogle.js script only needs to be loaded once on your page. This is done by the subown.js JavaScript library, which creates a <script> element that starts asynchronously downloading the adsbygoogle.js script from //pagead2.googlesyndication.com/pagead/js/adsbygoogle.js.

For Subown to work properly it's important that the subown.js script gets loaded and executed before the ad units get rendered by the adsbygoogle.js script inside the particular <INS> DOM elements. The call to adsbygoogle.push() instructs the adsbygoogle.js script to fill the corresponding unfilled slot.

Please be assured that you won't violate the AdSense program policies if you don't include the line

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

on each ad unit. For more information we refer to About the asynchronous ad code - Ad code implementation | AdSense Help and An async script for AdSense tagging | Google Developers Blog.

2. The line

<script>(subown = window.subown || []).push({ params: { ad_type: AD_TYPE }});</script>

is added at the bottom of the ad code. subown.push() tells Subown if the ad type is "Text & display ad" (AD_TYPE=1), "Text ad only" (AD_TYPE=2), or "Display ad only" (AD_TYPE=3).

The final Subown compatible AdSense ad code may look like this:

    <ins class="adsbygoogle"
        style="display:inline-block;width:300px;height:250px"
        data-ad-client="ca-pub-xxxxxxxxxxxxxxxx"
        data-ad-slot="6440411535"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>

    <script>
    (subown = window.subown || []).push({ params: { ad_type: AD_TYPE }});
    </script>
Note this card shows sample code only, please don't use it in your own site's HTML. Use the Subown AdSense snippet tool to create your ad code.

Dynamical Publisher Id And Ad Slot Id

By implementing Subown into your website you share your AdSense ad placement rights with the community. Subown may dynamically replace the AdSense ad unit's publisher ID (data-ad-client) and the ad unit's ID (data-ad-slot) before loading the adsbygoogle.js script in case that a Partial Owner's or Subown's ads are shown.

For more information about how Subown selects the publisher of the ad we refer to Subown Algorithm and Ad Placement Rate.

Advertisement