I think you want one of these. I'm not sure which:
OnHandleRequest — Fires when any request for a resource is received in the front end.
OnWebPageInit — Fires after determination that the site is online and the requested resource is located.
OnLoadWebDocument — Fires after the requested resource is loaded, but before it is parsed.
OnParseDocument — Fires just before the MODX tags are processed.
And one of the following (again -- not sure which, but I think it's the first one) to test them:
<?php
$modx->resource->set('template', 12);
<?php
$resource->set('template', 12);