One way I was thinking of was creating an updatable view, which is initialized to NULL. As SELECT queries take place, I can update the view to include the new rows.
Why you just create your track function and a view to call it?
Example:
BEGIN;
CREATE TABLE foo (id SERIAL PRIMARY KEY, data TEXT);