Want to add some extra bits in the head of your document, like tracking codes, custom javascript etc? Then use wp_head:
add_action( 'wp_head', 'YOUR_SCRIPT_IN_HEAD_FUNCTION' );
function YOUR_SCRIPT_IN_HEAD_FUNCTION() { ?>
';
If you want to add a bit of code to the page the safest one – which add the code just before the closing </body> tag is:
add_action( 'wp_footer', 'YOUR_CODE_IN_FOOTER_FUNCTION' );
function YOUR_CODE_IN_FOOTER_FUNCTION() { ?>
Some HTML code here
However, if you want your code in the body but a bit higher up the page you could try wp_body_open which will insert your code after the opening <body> tag – BUT only if your theme supports it.
add_action( 'wp_body_open', 'YOUR_CODE_IN_BODY_FUNCTION' );
function YOUR_CODE_IN_BODY_FUNCTION() { ?>
';