Archive: Google
May 1, 2008
Server-side Google Analytics
Peter van der Graaf did a little analysis of the URLs that are generated by the Google Analytics Javascript API and put together a very useful tutorial for building Analytics-enabled applications without the use of Javascript.
When you look at the analytics javascript code you see that it combines several sets of data into an image request. This image request sends the right data to Google (not the javascript). When you know what url you should use for the image, you can call the image directly and send the same data. Of course you need to be able to request the image url and that isn't easy from another image, rss feed or pdf. This is why we request it "server side".
You can add the code to the PHP that drives a blog site, for instance, and generate page views when your RSS feed is hit. You can even write a very simple script to proxy images and downloads, which will let you track hit data for all files on your site, not just the html pages viewed by a javascript enabled browser.
Taken a step further, you could even use this on the client side, triggering analytics views from standalone Flash apps or even desktop applications.
The one thing you need to keep in mind is that server-side analytics requests will appear to come from your server, not the client's machine. So while you can track page views and download events this way, you'll loose a lot of the information about your user base. Because of this, it would probably make sense to use a separate tracking ID for the server side events.
Google Analytics Without Javascript
Posted by Jason Striegel |
May 1, 2008 08:27 PM
Google, PHP, Statistics, Web, Web Site Measurement |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
April 11, 2008
Automatic outbound link analytics with jQuery
I had the challenge of adding Google Analytics tracking code to all the outbound links on a site I've been working on. There are hundreds of these links scattered around the site, so rather than try and edit a bunch of links, manually adding onclick handlers in an error-prone fashion, I decided to get lazy and write some code to handle it for me.
First I was thinking about doing some sort of regular expression search and replace throughout the site and database, but that reminded me of CSS3 selectors and their ability to do simple pattern matching. I've seen people apply a special style to outbound links this way, so after a few minutes of monkeying around with things, I now have a chunk of jQuery that will automatically track clicks on all outbound links.
Here it is, in a nutshell:
jQuery(function($){
// Match all anchor tags in the "maincontent" div with
// urls that begin with "http" but don't contain the
// string "yourwebsite.com"
$('#maincontent a[href^="http"]').not('a[href*="yourwebsite.com"]').click(function(){
try {
// Get the href url and toss out the "http://"
var href = $(this).attr('href');
if ( href.indexOf("://") > 0 ) {
// Track the page in Google Analytics as
// "/tracking/outbound/www.somesite.com/foo"
var outbound = '/tracking/outbound/' + href.split("://",2)[1];
pageTracker._trackPageview(outbound);
}
} catch( e ) {}
}
}
With this running, all of my internal pages get tracked as usual, and any external links will appear as pageviews that look like "/tracking/outbound/www.somesite.com/foo".
If you link out to many different pages on several sites, keeping the full site url in the tracking code and building these deep paths is particularly useful. Google Analytics will allow you to drill down into the tree like it was normal content and quickly pull numbers on how many total outbound clicks you received (/tracking/outbound), how many went to www.somesite.com (/tracking/outbound/www.somesite.com), and how many people clicked out to a particular page on the site.
This saved me quite a bit of time and is immensely more flexible than any other outbound tracking method I've used. I hope this helps someone else. Drop me a line in the comments if this works out for you.
Update: it looks like I wasn't the first to do this. An article by Rebecca Murphey shows how to do something similar, while also adding the referring post title to the tracking code. Pretty cool stuff, I must say.
Posted by Jason Striegel |
Apr 11, 2008 10:57 PM
Ajax, Google, Statistics, Web, Web Site Measurement |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
March 20, 2008
Visualization API for Google Docs

This looks really useful. Google recently released an API for using Gadgets and visualizations inside of (or pulling from) the Google Docs spreadsheet system. Developers can create useful visualization models, like Gantt charts or geographic heat maps, and Docs users can use these tools inside their own documents.
The Gadgets in Docs framework also allows the visualizations to be plugged into iGoogle, so you can have an up-to-date visualization data on your iGoogle page that pulls from spreadsheet data in real-time. I found the timeline gadget, pictured above, to be particularly useful, but if you don't find the particular visualization you need, you can now go ahead and make it yourself.
Visualization API [via Google Blog]
Example Visualization Gadgets
Posted by Jason Striegel |
Mar 20, 2008 09:31 PM
Google, Life |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
March 10, 2008
SketchUp has a Ruby API

I guess it's been available for a few months, but I just noticed that there's a Ruby API for Google SketchUp. Looks like a cool tool for extending the building interface, integrating SketchUp entities with external software, and building procedural stuff, like making terrain or stairs.
Here's a video of SketchUp developer Mark Limber talking about some of the possible ways to extend the software with the Ruby API.
Google SketchUp Ruby API - Link
SketchUp API Blog - Link
Posted by Jason Striegel |
Mar 10, 2008 07:05 PM
Google, Google Earth, Google Maps, Software Engineering |
Permalink
| Comments (2)
| TrackBack
| Digg It
| Tag w/del.icio.us
January 18, 2008
Homebrew Google Analytics API

It's too bad that Google Analytics doesn't have an official API, but Chris Riley came up with a fun solution for pushing analytics content into a format that is easily accessible from your web applications.
Using Google Analytics' scheduled reporting feature, you can have an analytics report automatically sent to a public, read-only Google Group in XML format. From there, the group's latest post can be pulled in through Yahoo pipes where it is filtered and exposed as a JSON service, ready for you to pull into a web application via Javascript. Yoikes!
Chris' example shows you how to do this to add a popular posts feature to your blog. You should be able to tweak the code to export other information from Analytics as well, including geographic distribution, popular search terms, or even visitor and pageview data.
No Google Analytics API? No Problem! - Link
Posted by Jason Striegel |
Jan 18, 2008 09:04 PM
Ajax, Google, Web, Yahoo! |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
August 31, 2007
Google Earth has a flight simulator

The latest version of Google Earth contains a hidden feature: a full-fledged flight simulator! Press Command+Option+A in OS X or Ctrl+Alt+A on a PC or Linux box and you'll be greeted with a hidden dialog box that lets you choose an aircraft (F16 or SR22) and an airport. Once you've made you selection, you'll be placed inside the aircraft. You can then fly around the globe in a free flight simulator, viewing the scenery that is pulled from Google Earth's map files.
I wasn't able to get things to work at first, so if the key combo doesn't work for you, try zooming way into Earth and try again. It seems like you can't activate the feature when you are out in space looking down on the eath. Once you've activated the feature, it will be available from the Tools menu.
Force feedback joysticks are supposed to be supported, though I've only been able to test with a mouse and keyboard. The basic controls are PageUp/Dn for thrust, G for gear up/down, Left/Right for aileron, Up/Dn for elevator and Shift+Left/Shift+Right for rudder. You can also click the screen to enable the mouse to control the aileron and elevator controls. See the link at the bottom for the full set of controls.
Google Earth Flight Simulator - Link
Keyboard Controls - Link
Download Google Earth - Link
Posted by Jason Striegel |
Aug 31, 2007 08:44 PM
Google, Google Earth |
Permalink
| Comments (1)
| TrackBack
| Digg It
| Tag w/del.icio.us
August 14, 2007
Google Office Hacks

Philipp Lenssen of Google Blogoscoped is working on an upcoming book on Google Office:
I'm happy to tell you I've started writing a book with O'Reilly's Maker Media group, currently titled Google Office Hacks! The book will not focus on search, but on the existing & growing applications suite Google provides. It will provide tricks to get things done with Google Docs, Google Spreadsheets, Gmail, Google Calendar, iGoogle, Google Analytics, Maps, YouTube, SketchUp, Presentations (if Google decides to release it!) and more...For this book, we'd love to get your hacks in it too.
Check out Philipp's blog post for more details, and keep an eye on Hackszine.com for more information - Link
Posted by Brian Jepson |
Aug 14, 2007 09:08 AM
Google |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
July 21, 2007
Use Adsense on password protected sites

In order to display relevant advertisements, Adsense has its own web crawler which scans Adsense enabled URLs for page content. This helps Adsense get a clue of what the particular page is all about, and enables it to display ads with purchased keywords that match your content.
For forums and other password protected sites, however, the Adsense crawler is usually able to see only an error or login request page. With little information to go on, ads cannot be placed correctly, so Adsense on password protected sites was a bit of an impossibility. Until Google added the "Site Authentication" feature, that is.
If you go into Adsense setup, there's a new tab called "Site Authentication". On that tab, you can configure Adsense with the login and password information that it needs to authenticate with your site before indexing your pages for content. You'll need to know a little about how your login form is configured for your particular site, but it's fairly simple to figure out from looking at the source. Here's an example:
Locate Form URL and Variables
The login form on a Drupal website that I run looks like this. I've stripped out everything but the form anf input fields, and your site may differ, but you can use this as an example:
<form action="user/login?destination=node" method="post"> <input type="text" maxlength="64" class="form-text" name="edit[name]" id="edit-name" size="15" value="" /> <input type="password" class="form-password" maxlength="64" name="edit[pass]" id="edit-pass" size="15" value="" /> <input type="submit" class="form-submit" name="op" value="Log in" />
So from this I know that the form method is "POST", the URL for the login page is http://examplesite.com/user/login?destination=node and the're are two user input fields for the username and password: "edit[name]" and "edit[pass]". There is also the submit button, with the name "op" and the value of "Log in". The submit button value may or may not be important for the log in script, but we'll use it just in case.
Give Adsense Authentication Information
Now you can jump over to the "Site Authentication" page and add the necessary information. First, make a speical username and password on your site for Adsense to use. Adsense will be using this account to log in and browse your site's content, so make sure it has the neccessary permissions to see everything that you want ads to appear on. For the purposes of this example, let's say the new user is "adsenseuser" and the password is "123abc".
- In the restricted directory or url field, put the portion of your site's URL that restricted content is under. This might be http://www.restrictedsite.com/ or https://www.testsite.com/membersonly or something like that.
- For the authentication url field, enter in the url that you discovered earlier which the normal log in form is posting to. In the above example, this was http://examplesite.com/user/login?destination=node
- Select the correct authentication method. This will be "POST" in most scenarios.
- Enter the login form field names and values. Our example has three fields: "edit[name]", "edit[pass]", and "op". The values in this case would be "adsenseuser", "123abc", and "Log in", respectively.
When you've finished, save your settings and you'll be directed to Google's webmaster tools to "claim your site". This is the same tool used by Sitemaps, and all you'll need to do is upload a small file to your site. This proves to Google that you are the owner of the site.
After your site is verified, and Adsense has had some time to index your site, you should notice more targeted ads start appearing on your restricted pages.
Posted by Jason Striegel |
Jul 21, 2007 05:39 PM
Google |
Permalink
| Comments (1)
| TrackBack
| Digg It
| Tag w/del.icio.us
July 1, 2007
Google Desktop for Linux (sorta)

Google Desktop is now available for Linux. Unfortunately, it's not open source, and it's about equivalent to version 1 for Windows, so it won't provide all the extras like desktop gadgets.
That said, it's still a desktop alternative to find and grep, and you can search your Gmail while offline - Link
Posted by Jason Striegel |
Jul 1, 2007 06:54 PM
Google, Linux, Linux Desktop |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
June 13, 2007
Use a Google Spreadsheet as a simple CMS

Using Google's Spreadsheet API, you can create a simple CMS for your website extremely easily. It's as simple as making a new sheet with key/value pairs for any fields you want dynamically populated. You can then access the data from javascript via the JSON API. Any updates to the spreadsheet will be immediately reflected in your page.
The only downside to this approach is that the content of your page is populated by Javascript on the client side, so search engines won't see the content of your pages during a crawl. You could overcome this obstacle by using the PHP API to pull the spreadsheet data and render the HTML on the server side.
Simple CMS using Google Spreadsheet API - Link
Google Spreadsheets Data API - Link
Posted by Jason Striegel |
Jun 13, 2007 08:52 AM
Google, Web |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
May 30, 2007
Gears API: create web apps that work offline

Google released a new Javascript API today called Gears that makes it possible to write modeless web applications that will function offline. A browser plugin is available for IE and Firefox (OS X, Linux, and Windows), with Safari support planned for the near future. The plugin will need to be installed by users of Gears-enabled applications.
From what I can see--and keep in mind that I haven't used the API yet--there are 3 basic services that the API provides:
- local file resource storage and caching so that you can view files after disconnecting
- a client-side SQL database that can be used by Javascript to store and fetch data
- a worker pool module for running asynchronous background processes
The obvious use for this is to make stateful applications that continue to operate when you're offline, but maybe there are some privacy opportunities here too. Today, applications come in primarily two varieties: apps with user data and software stored locally, and web-based applications that execute and store data on the server. What I'm curious to see is if developers will begin making a third, hybrid category of application, where software release and maintenance is web-based and global data is available for local consumption, but the storage and processing of user-specific data takes place on the client side, safe from unwanted profiling.
Google Gears API Developer's Guide - Link
Posted by Jason Striegel |
May 30, 2007 07:36 PM
Ajax, Data, Google, Web |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
May 17, 2007
Corral a bunch of random Slashdotters into a chat room

Steve Pasetti posted a nifty trick for creating an ad-hoc chat room full of random Slashdot readers:
How do you get a bunch of folks from Slashdot into a room to chat?Post a link to a Google Spreadsheet in the comments...
Impromptu Chat Room - Link
Posted by Brian Jepson |
May 17, 2007 01:04 PM
Google |
Permalink
| Comments (1)
| TrackBack
| Digg It
| Tag w/del.icio.us
May 12, 2007
iGoogle Greasemonkey hacks

If you use Firefox with Greasemonkey, there are a lot of really nice scripts available for tweaking the iGoogle interface. You can resize columns, replace the iGoogle logo, or, my personal favorite, add some subtle transparency effects to the search interface so that it blends in with the theme you are using - Link.
Related:
Posted by Jason Striegel |
May 12, 2007 07:20 PM
Firefox, Google |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
May 1, 2007
Make your own gadget (google)

Starting today you can use Google to make your own "gadget" that can be added to your site. From the Seattle PI -
Getting more people to log in to the site is important to Google because it allows the company to log more data that helps its algorithms better understand the nuances underlying many search requests that could have multiple meanings.iGoogle - Link.With a personal login, "the search engine is your friend and starts to know something about you" Mayer said during a Monday briefing with reporters.
With more knowledge about a person, Google theoretically will be able to deliver more relevant search results and also select ads that are more likely to induce the revenue-generating clicks that generate most of its profit.
*This is starting to become The Forbin project.
Posted by Phillip Torrone |
May 1, 2007 03:00 AM
Google |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
April 25, 2007
Unofficial Google Translate API

The Unofficial Google Translate API is a combination javascript library and php service that allows you to do AJAX-style language translation. The PHP script serves as proxy to Google's Translate utility, passing data to and from Google on behalf of the javascript code.
Unofficial Google Translate API -Link.
Inspired by Philipp Lenssen's Google Translate API "Announcement From 2009" -Link.
Posted by Jason Striegel |
Apr 25, 2007 09:10 PM
Ajax, Google, Language |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
Bloggers
Welcome to the Hacks Blog!
Categories
- Ajax
- Amazon
- AppleTV
- Astronomy
- BlackBerry
- Blogging
- Body
- Cars
- Cryptography
- Data
- Design
- Education
- Electronics
- Energy
- Events
- Excel
- Excerpts
- Firefox
- Flash
- Flickr
- Flying Things
- Food
- Gaming
- Gmail
- Google Earth
- Google Maps
- Government
- Greasemonkey
- Hacks Series
- Hackszine Podcast
- Halo
- Hardware
- Home
- Home Theater
- iPhone
- iPod
- IRC
- iTunes
- Java
- Kindle
- Knoppix
- Language
- LEGO
- Life
- Lifehacker
- Linux
- Linux Desktop
- Linux Multimedia
- Linux Server
- Mac
- Mapping
- Math
- Microsoft Office
- Mind
- Mind Performance
- Mobile Phones
- Music
- MySpace
- MySQL
- NetFlix
- Network Security
- olpc
- OpenOffice
- Outdoor
- Parenting
- PCs
- PDAs
- Perl
- Philosophy
- Photography
- PHP
- Pleo
- Podcast
- Podcasting
- Productivity
- PSP
- Retro Computing
- Retro Gaming
- Science
- Screencasts
- Shopping
- Skype
- Smart Home
- Software Engineering
- Sports
- SQL
- Statistics
- Survival
- TiVo
- Transportation
- Travel
- Ubuntu
- Video
- Virtualization
- Visual Studio
- VoIP
- Web
- Web Site Measurement
- Windows
- Windows Server
- Wireless
- Word
- World
- Xbox
- Yahoo!
- YouTube
Archives
Recent Posts
- Debian/Ubuntu users: update your SSL keys and certs
- drop.io - simple anonymous file sharing
- Cross browser session data with Javascript
- A VAX in your Linux box
- Reading EXIF data from images in Javascript
- Processing.js - visualization library for Javascript
- DIY multi-touch on OS X
- Radio controlled lawn mower
- Using the Canon Hacker's Development Kit
- Cornell University's student microcontroller projects - Spring08
www.flickr.com
|





Recent comments