Adding static content to footer or header


I would like to add static content (in this case piwik/matomo javascript) that should be loaded with every page.

Is there a generic way to do so without having modifications over written by updates ? Think of personalizing footer for example.

Could someone tell me how to do it please ?