If I needed code to be implemented across all the pages, I created a custom html widget and placed it in the sidebar. As the sidebar is visible on all pages the code will be executed all the time.
This protected my custom code from having to edit any pages after an oxeall update as it may overwrite any hard coded changes I made.