What Hook to Use to Execute a PHP on Every Page? I'm new to creating module in Drupal 7 and wondering what hook to use to execute a PHP script.

I use this tutorial but it it explain a different approach.

What I want is simply execute this code in every page:

db_insert('ap_visits')
    -&gt;fields(array(
        'id' =&gt; NULL,
        'length' =&gt; $t,
        'url' =&gt; $url,
        'current_ip' =&gt; $current_ip,
        'user_agent' =&gt; $user_agent,
        'date_start' =&gt; date("Y-m-d H:i:s"),
        'is_bot' =&gt; $isbot,
        'is_logout' =&gt; 0,
    ))
    -&gt;execute();


Note that I have already created .module and .info file. All I need is to know what hook to put the code above.

Thanks for any help.
I would look into hook_init() if you don't require this to be run on cached pages, hook_boot() if you do.