Yes, I know you have to embed the google analytics javascript into your page.
But how is the collected information submitted to the google analytics server?
To expand on other very good answers, Google does provide an API to track async "virtual pageviews" which are reported by website authors themselves in their scripts to Google.
_gaq.push(['_trackPageview', 'my_unique_action']);
They provide it so it is possible to track actions that are not part of regular page views and http requests.
Async tracking guide: http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html#Syntax