How can I conditionally add a parameterized variable to my themes based on URL?
You're on the right track: it'll be much more straightforward to stick this in a module where you have access to the menu system, and the most straightforward way to expose the data to the node template is through preprocess functions.

First, create an implementation of hook_menu():

function example_menu() {
  // Only two things specific to your case is page callback 
  // and page arguments. Other options taken from node_menu(): customize as
  // you see fit.
  $items['node/%node/animal/%'] = array(
    'title callback' =&gt; 'node_page_title',
    'title arguments' =&gt; array(1),
    'page callback' =&gt; 'example_animal_view', 
    'page arguments' =&gt; array(1, 3), // Pass node object and animal ID
    'access callback' =&gt; 'node_access',
    'access arguments' =&gt; array('view', 1),
  );
  return $items;
}


Then create your callback, which will display the node as normal (including using the node template) if your animal check succeeds:

function example_animal_view($node, $animal) {
  if (animal_exists($animal)) { // Replace with your own check
    return node_page_view($node);
  }
  // Return a 404 if the check failed
  return MENU_NOT_FOUND;
}


Now, to expose the animal ID to node.tpl.php; you could either add it to the node object via the Field API, but in this case—since you're just using it for theming purposes—it's much easier to just add it to the template variables in a preprocess function:

function example_preprocess_node(&amp;$variables) {
  if (arg(2) == 'animal') {
    $variables['animal'] = arg(3);
  }
}


You could do this last part in your theme, but I'd keep it in the custom module to encapsulate the functionality so it's available in every theme.

Finally, in node.tpl.php, just reference $animal.