How to create a module to insert some analytics code in the footer of website pages? I want to create a module for Drupal 7, with a simple scope. It's just to insert the analytics code in the footer of website pages and with an option to exclude some pages if required.

I just need a module configuration page with 1 text field to enter the Analytics ID. And a text area below it, just like in blocks configuration page, which allows you to show the block on specific pages.

After this info is saved, the code should be inserted in the footer of each page, with that Analytics ID.

Can anybody tell me what hooks I will need to implement this functionality?
These two links should get you started:

https://www.drupal.org/node/206761

https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_page_alter/7