CodeFund Feature: Ad Callbacks

Publishers can grow with CodeFund without sacrificing revenue by using ad callbacks

Building an ad platform can be tricky. Not only from a technical aspect but also regarding growth. It reminds me of the “which came first, the chicken or the egg” question.

0_U7IL_CAGKe49GdLp (1).jpg

Which came first?

In our case, the chicken would be the publisher, and the egg would be the advertiser. Publishers attract more advertisers, and advertisers attract more publishers.

Last year we decided to invest in ourselves and play the part of the advertiser when paying ads ran out. These internally paid ad campaigns helped ensure that we had enough funds to draw in more publishers. As well as this worked, it ended up costing us all of our profits. Did it work? Yes. Was it sustainable? Hell no.

In 2019, we decided to stop paying publishers to place fallback ads. This decision will allow us to realize a profit, which of course makes it so we can be around for the foreseeable future. However, this may come at a cost to some of our larger publishers because they may be displaying unpaid fallback ads.

Ad Callbacks

To resolve this concern, we have recently added callbacks into our funder script that can be subscribed to by the publisher.

Here’s the code that generates the funder script:

The lines to note here are 3, 11, 14, 18 and 21. We trigger a new event called ‘codefund’ which contains the status of the embed. If the status is ‘ok,’ then we know that an ad rendered successfully. If the status is ‘no-advertiser,’ we couldn’t find an advertiser for the given property and visitor.

So let’s say one of our publishers wants to use CodeFund as the first option for ads (this happens a lot because we pay publishers higher rates). Now they can put in place an event listener that will render an ad from another network if there are no paying CodeFund ads.

Here's an example:

Now that this change is in place, our publishers can grow with us without sacrificing their revenue.

To learn more, view our documentation at

If you are interested in being a publisher with CodeFund, or advertising to our fantastic network of developers, visit