DEV Community

Cover image for SEO friendly Random Ads Manager creation
Stojan Nikolovski
Stojan Nikolovski

Posted on

SEO friendly Random Ads Manager creation

Struggling to monetize blogs I've run over the years I've came to idea to display my affiliate links and promote my services as image ads a long time ago. This way could monetize a new website from day one. Not a bad idea.

Placing images with links is a no-brainer but will have to done manually or not if using a CMS and some plugin to rotate the ads. Or simply use Adsense or some other advertising network.

Neah! This doesn't work for me!

Plugins will show only one ad unit at a time and will need a lot of visits to see any buck. If running affiliate offers maybe, just maybe if you're lucky you can earn the same couple of dollars from just one affiliate sale.

I wanted to have full control of the ads shown on my blog, ads, images, ad placement, target links and all this have to be SEO friendly if possible.

As such a solution doesn't exist (or I didn't find something that meet my criteria) last option was to create it my self.

I've get my hands dirty and this is what I did:

  1. Made a plan and steps what the app/script should look and what should do:
  2. Will need a login to access the main interface where ads can be added, set or deleted. Will need to store entered data and create ad formats that will actually display ads by randomly pull data from file where stored
  3. Choose what technologies to use
  4. Write the code and test it

  5. PHP for the backend with javascript for the ad display and front end as plain HTML and CSS with a little use of lightweight W3CSS for faster styling. I was a bit in hurry to finish it in a day and might go back and change the styles turning into pure custom CSS without any external frameworks.

  6. Writing the code is always the most time consuming part of web development. No exceptions, especially when you stuck with a login form that let everybody log-in !?

Image description

Next was coding the main panel for managing random ads. First thing was creating a form where you can add a new ad with all the necessary fields:

  • Target URL - an affiliate link or a link to any page or website you choose
  • Image URL - the absolute path of the image to be shown in the ad
  • Description - this is the description of the ad, but also used as ALT tag for the images in the ad
  • Display Duration (in Days). Oh the ads have expiration date if plan to sell ad space and monetize your website further this way
  • And of course a submit button of a kind that process the form and store data in a JSON file while displaying the ads added to a rotation pull

Here is the form:

Image description

Did I say ads are randomly shown? Why should randomly display ads at a first place?

This is made because either way users will see the same ad over and over. Spicing things even more a different ad format was created showing 4 ads in row instead of one!

Add as many ads as you want. They will be stored in external JSON file and fetched randomly from there before displayed by the ad format logic written in JavaScript. Ads stored in the JSON have expiration date checked by the Random Ads Manager and will stop showing when expire.

Ads are responsive and SEO friendly. Just choose the right ad format that suits your needs, copy/paste some code into your website or in an article right in the place where want to appear.

Image description

That's it. You can now place ads where ever you need them and monetize your website from day one with even a handful of visitors.

Random Ads Manager is free.

Can get it on Github

Or test the ads and try the demo

You'll love it!

Top comments (0)