EthicalAds Client

This is the client library used to add an ad placement from EthicalAds to your site. To get started, you will need to first become a publisher, and then you can configure your site.



There are two pieces required to add an ad placement to your site. You will need to create an empty <div> element where you would like to place a new ad placement, and you will need to include the client library.

To start, add the following in your site’s <head>:

<script async src=""></script>

To add the placement on your site, you will need to add an empty <div> with some added data attributes to configure the ad placement:

<div data-ea-publisher="..." data-ea-type="text"></div>


The following data attributes are supported on the ad placement element:

(Required) The EthicalAds publisher id for your account.
The ad placement type. This value can be either image or text – the default is image.
id (optional)
A placement identifier. If you define an id and enable placements reporting, this will allow you to see reports for each id.
data-ea-keywords (optional)
A pipe (|) separated array of keywords for this ad placement. This is page-specific (not publisher-specific) keywords related to where the ad is shown.
data-ea-campaign-types (optional)
A pipe (|) separated array of campaign types (“paid”, “community”, “house”). This can only further reduce campaign types, not allow ones prohibited for the publisher. This is useful when you want certain users to not get certain types of ads.


The following themes are available on all ad placement types:

Raised theme

This is the default theme used if you do not specify a theme.

<div data-ea-publisher="..."></div>

Or you can also explicitly use the theme name:

<div class="raised" data-ea-publisher="..."></div>

There are also dark variants for all of the themes. The dark variants can be used with the dark class:

<div class="dark raised" data-ea-publisher="..."></div>

Ad Types

Image placement

The image ad placement type has two variants: horizontal and veritcal. Vertical image placements are the default ad type. To use the horizontal variant, use

Vertical image

<div data-ea-publisher="..." data-ea-type="image"></div>

Horizontal image

This variant can be used with the horizontal theme variant class:

<div class="horizontal" data-ea-publisher="..." data-ea-type="image"></div>

Ad placement reporting

EthicalAds allows you to track all the different ad placements that you have on your site. This means that if you have an ad on your homepage template, blog listing template, and blog post template you can track them all seperately.

This is enabled by adding an id to the EthicalAds div on your site:

<div data-ea-publisher="..." id="blog-sidebar"></div>

This feature is disabled by default, you can go to Settings > Record placements to enable this feature.


We recommend that you provide an id for each of your different ad placements. This will enable you to track the performance of each placement, and make adjustments that increase your CTR.

Page-specific keywords

EthicalAds allows our advertisers to target ads based on the content of pages. This provides value for everyone, giving users more relevent ads while still respecting their privacy.

Publishers can set page-specific keywords dynamically on each page of their site based on the content of the pages. For example, if you have a blog post about Kubernetes, you could set tags of devops and kubernetes.

This is enabled by adding an data-ea-keywords to the EthicalAds div on your site. They are |-seperated, so you can include multiple for a single page.

<div data-ea-publisher="..." data-ea-keywords="devops|kubernetes"></div>


It’s possible to extend the ad client, even if you are loading the client in your browser through a request. After loading the script, there will be an ethicalads global/window instance that can be used to extend the ad client interface.

The easiest place to extend is the ethicalads.wait promise instance. This resolves to an array of placements that were successfully configured – if no placements were loaded successfully, this will be an empty array.

The ethicalads object needs to be instantiated first. If you aren’t loading the ad client library asynchronously, you can delay execution by loading your additional script after loading the ad client.

If you are loading the ad client library asynchronously, you should wait for a document ready event. For example, using jQuery:

$(document).ready(() => {
  ethicalads.wait.then((placements) => {
    console.log('Ads are loaded');

Showing content when there isn’t an ad

The biggest use-case is to show backup content when we don’t have an ad to show. Many of our publishers prefer to serve EthicalAds, but while we’re still building the network we might not have a 100% fill rate.

You can show backup content with a code snippet like this:

<script src=""></script>
ethicalads.wait.then((placements) => {
  if (!placements.length) {
    console.debug('Loading backup content');
    div = document.querySelector('[data-ea-publisher]')
    div.innerHTML = '<p>Check out our first-party ad content.</p>'
  } else {
    console.debug('EthicalAds are loaded');


You need to have Allow house campaigns disabled in the ads dashboard, otherwise we will always return a house ad. Go to Settings > Control advertiser campaign types to disable it.

Becoming a Publisher

Visit EthicalAds to apply to be a publisher.