We all have added ads and other code snippets to our functions file or footer files in the past. Most modern themes come with a special section for adding such code snippets. The Woody Ad Snippets plugin can also help. It lets you create and store code snippets on your site. You can use shortcodes to add the code to your pages anywhere.
This plugin supports Google Analytics tracking code, PHP code, social media widgets, AdSense ads, and a whole lot more. You can insert code in the header or footer of your site or display ads before/after post/content/paragraphs.
Woody Ad Snippets has conditional logic options for post/page types, devices, roles, referring URL, and a whole lot more. This is a free plugin.