If it needs to go before </body> the best place for it would probably be the PAGE_CONTAINER template as this is where the </body> tag lives.
There's actually a template hook, so if you wanted this to be an add on, it looks pretty straight forward. I could make that for you.
All I'd need is for you to provide the code (maybe best in a private message so as not to reveal your client ID or anything).
Then I can get the code inserted into the appropriate hook, and have an options page where you can configure your client ID. A bit like how the Google Analytics feature built in works.