Close Search Box
Search Box

Search: From:

Close
Newsletter

9Tutorials to your Inbox



Get Google Adsense statistics by using PHP

Get Google Adsense statistics by using PHP
Author lv1 (2000/5000)
2,194 views
1 Star2 Star3Star4 Star5 Star (5 votes, average: 4.8 out of 5)

Why not let your own script fetch the statistics directly from google adsense reporting site? It’s always much easier to have the data locally in your own database, and then create scripts to display the stats in the way you are interested in.

I will now give you the code that collects the present stats from adsense, for any channel you specify. Because I also love to work with databases, we will store the results in mysql.

The basics behind the script is that you choose what channels you want to fetch stats for, and then you let your script do that as often as you which. You can schedule this script with crontab or something similar as often you which. Don’t do it more often than every 15 minutes, because I have heared something from google that you are not allowed to script things mroe often against adsense …

Here’s what to do:

  1. Login to adsense and click on “advanced reports”. Create channels if you don’t have any yet, because this script shows stats for separate channels.
  2. This part might be the most complicated, but still very easy. “View source” for the page and search for select name=”reportId”. Scroll further out on that row in the source and look for your channel names. You will find something similar to this Cholesterol-week . Write down the number and the name on a paper or somewhere. Do this for every channel you want to track.
  3. Create a database and assign a user with a password for that.
  4. Run this sql code:
  5. Save the file you see in the blue box below as adsense.php or similar. Look at the first lines where you need to fill in your details. Both for your adsense account and your db details.
  6. In the file you need to enter all channelId’s and channelNames in the array. Just increase that array if you have more channels!

I have not created any script to display the stats yet, but that might come in the future :-) For now, enjoy the script and let me know if you like it!

Here is the script:

Copyright @ Gary Logsdon 2007

del.icio.us:Get Google Adsense statistics by using PHP digg:Get Google Adsense statistics by using PHP spurl:Get Google Adsense statistics by using PHP newsvine:Get Google Adsense statistics by using PHP blinklist:Get Google Adsense statistics by using PHP furl:Get Google Adsense statistics by using PHP reddit:Get Google Adsense statistics by using PHP blogmarks:Get Google Adsense statistics by using PHP Y!:Get Google Adsense statistics by using PHP magnolia:Get Google Adsense statistics by using PHP segnalo:Get Google Adsense statistics by using PHP
Login




Friends' Sites

Contact Us

Categories

Sponsors

Featured Links

Post a Comment »








Safari hates me

Comment Guidelines

  • Hyperlinks are automatically generated.
  • <em>italic</em>
  • <strong>bold</strong>