Google AdSense with Jumi
I will show you how to develop your own module and/or plugin on a quite wide spread practical business application, Google AdSense for content.
Google AdSense for content is a service of Google which enables to earn some bucks (i.e. $$$) by presenting Google advertisements on your web.
At the end of this lesson you will be able to present Google ads in a module position and/or in a content of your articles at your Joomla! webpages.
All ads on this site - not Google ones only - are done via Jumi.
Google AdSense for
As a prerequisites you will need
- Jumi module or/and Jumi plugin installed and enable on your site,
- Google AdSence account.
Google AdSence account is available for free and Jumi extensions are available at this website for the same price (yes - the world is wonderful place to live! At the least sometimes.).
After approving your request, which will take Google a day or so, you will get a mail from Google explaining what to do:
STEP 1: Activate your account...STEP 2: Paste the AdSense ad code...STEP 3: See the results...
So let us start.
After your account activation you will be redirected to your AdSense central. There are three tabs there: Reports, AdSense Setup and Account. Press Setup and then AdSense for Content. Then Select either Ad Unit or Link Unit. In this example I will follow Ad Unit branch; the difference between both branches is from our technological point of view negligible. Select appropriate format and colors that suits you webpage graphic design (i.e. your template_css.css). There are some minor settings that are not substantial for our learning purpose.
At the very end you will be presented your AdSense Code more or less similar to this one:
where pub-8738153579262497 represents your unique client's number given to you by Google; it will be show in the code too.
Copy the code presented to you by Google into your favorite text editor. Not editor like MS Word, but pure text editor like notepad. This is very essential since the editors which enable text formatting (Word) insert some unwanted code into our code that must be pure as is.
Before the Google script, i.e. at the very beginning of code, copy the following line.
NEVER forget to start your Joomla! php code with these lines! They are very important for security reasons!
It prevents opening the php code directly bypassing the Joomla! environment.
The "security" lines introduced above work in both Joomla! 1.0.x and 1.5.x.
Save the code under any file name you like with .php extension. For example under the name googlead.php.
Upload the file into your Joomla! site into the appropriate directory. In the following I will use the term "pathname" to designate total relative pathname of the script.
The pathname term is described in Jumi usage in details.
Now you can make your ads visible in a module position or somewhere in your articles. It is done via module and plugin respectively.
Placing ads into a module position
Go to the backend (Admin) of your Joomla! where a list o installed modules is. Find "Jumi". Copy this module. You will see a module named "Copy of Jumi". Open it for the editing. Give it appropriate name, e.g. "Google Ad". Select a place (module position) you wish Jumi module will show its content, e.g. "right".
At the Parameters form you have to fill only Pathname field, e.g. includes/google/googlead.php or so.
The actual pathname can differ. Especially in case you have set up default absolute path in a module parameter in the backend (valid for Jumi ver. > 1.2).
There are another fields in the Parameters section - they are not required here.
So let's make a final step: save your module and publish it.
Go to the frontend and see the results. If you can see nothing you have probably forgot to publish the module. Check it up.
Plugin - places ads into article content
If you have installed Jumi plugin do not forget to publish it.
Then open any article for editing and include into it the following code:
The actual pathname can differ. Especially in case you have set up default absolute path in a plugin parameter in the backend (valid for Jumi ver. > 1.2).
Save your article, go to the frontend and enjoy the result.
Dear reader. If you see Google Ads on your web pages you are not one of the dummies any more. You are The Junior Programmer indeed!
Good Luck in your further effort of developing your own custom modules and plugins!
You may have noticed Google Ads can be of various dimensions and graphical outlook. You can have one script file for each variant or you can have one script file for ALL variants. The decision "what Ad variant to show actually" can be driven by Jumi arguments.
Simple example. Lets have two Google scripts describing two different ads. A and B. We can paste both into our googlead.php and distinguish between them by php command "case". This command switches between ads scripts by Jumi argument.
Showing Google Ad of type A is simple:
as well as showing type B:
Again the Jumi plugin and Jumi module can share your script files.
So you can have all your favorite ads in a just one script file only AND show them in module positions or articles. If you wish.