Guides

Inserting Admob ads in mobile site

Admob is the leading provider in mobile advertising. It provides advertisements for Mobile Sites, Mobile Applications, Android Applications, iPhone Applications in a variety of formats so that they can be placed in an application created in any of the common languages (Perl, PHP, Java; etc). Admob does provides complete documentation about adding advertisements to applications but in case of Mobile Sites, they either don’t provide complete documentation or the users fail to understand it. So, to help out the users who aren’t able to insert admob ads in their pages, I’m creating this complete step-by-step guide. Kindly let me know your opinions and if the procedure worked for you or not. Note:The procedure is for an HTML based site. If you have a  site written in PHP, you need to make some changes in the process. You may not need to place the codes in PHP tags, if you have PHP based pages as they might already be open in your file. Lets come to the post title now. Here starts the guide:

  1. Go to your Admob Account, and Add your mobile site under ‘sites and apps’.
  2. After adding the site, you’ll see a set of codes. You need to choose PHP Curl.
  3. Copy the entire code to a notepad file and insert ?> at the very end of the file.
  4. Now, save the file as – admob.php .
  5. Now, create a new notepad file and insert the following code into it:<?php echo admob_request($admob_params); ?>
  6. Now save this file as admob_request.php
  7. Now, upload both these files (admob.php & admob_request.php) to the root directory of your website.
  8. You now need to make calls to these files from your HTML page, where you want to include the ads. To do that, move on to next step.
  9. Open your page (where you want to insert the ads) for editing in some HTML or text editor. You can chose from online editor (if your host provides) if it doesn’t you can use notepad too.
  10. Insert the following code at the exact location where you want to add the advertisement. <?php include("admob.php"); ?>
  11. It will show up advertisement at that place. If you need to add any more advertisements at the same page, insert the following code wherever you need more ads on the same page. <?php include("admob_request.php"); ?>
  12. For better ad functionality, you can call following code on command on any page: admob_setcookie()

That’s the whole procedure to insert the ads. Once the Test Ads starts showing up, change the value of  TEST_MODE in admob.php from true to false. You’ll see real ads showing up.

If you have any doubts or issues adding admob ads to your site, kindly let me know. I’ll try my best to help you.

Subscribe for email updates!

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 4,249 other subscribers