Display AdSense Earnings In Conky

Introduction

Adsense recently updated everyone to the new admin. The script is now updated to handle that.

Conky is a fantastic resource monitor for Linux/BSD that can be customized to not only show system statistics, but run external scripts as well. I've created a script that will display Google AdSense statistics directly into your Conky display.

Conky Example

I've also created a script for displaying your Project Wonderful Earnings in Conky as well.


Requirements
  • Conky
  • PHP with the curl extension

Usage

There are three things you need to change on the script to fit your needs. If you understand PHP it should be a breeze for you.

First, set your username and password by changing the values in the quotes.

$username = "username@example.com";
$password = "mypassword";

Next, change the output echo to fit your needs. The current configuration will display the monetary earnings for today.

echo "Today Earnings: $earnings[today]\n";

The values you can use with $earnings are $impressions, $clicks, $ctr, and $ecpm. The values you can use along with today are yesterday, last7days, thismonth, lastmonth.

echo "Last Month Impressions: $impressions[lastmonth]\n";
echo "Last 7 Day CTR: $ctr[last]\n";
echo "Yesterday ECPM: $ecpm[yesterday]\n";

You can easily combine and set the order for multiple options like below. This would display today's earnings - this month's earnings.

echo "Today: $earnings[today] - Month: $earnings[thismonth]\n";

To integrate this into Conky, add the following lines to your .conkyrc configuration.

AdSense Statistics:
${texeci 900 /location/to/adsense.php}

This will update your AdSense statistics every 15 minutes (900 seconds). You can change this value, but it might not be a good idea to poll your account too often.

Make sure the AdSense script is executable, by setting the correct permissions.


Download

AdSense PHP Script