Ad inserter is best plugin I tried. It's support many functions, also pro version available. The free version meets my needs.
wordpress.org/plugins/ad-inserter
16 code (ad) blocks
Syntax highlighting editor
Code preview with visual CSS editor
Automatic insertion before / after post, content, paragraph or excerpt
Automatic insertion before or after random paragraph
Automatic insertion before or after multiple paragraphs
Automatic insertion before or after any HTML element in post
Automatic insertion at relative position in posts
Clearance options to avoid insertion near images or headers
Automatic insertion between posts on blog pages
Insertion exceptions for posts and pages
Insertion of header and footer code
Insertion of Google Analytics, Piwik or any other web analytics code
Manual insertion: widgets, shortcodes, PHP function call
Sticky (fixed) widgets (the sidebar does not move when the page is scrolled)
Custom block alignment and style
Insertion of ads on AMP pages
Custom CSS class name for wrapping divs to avoid ad blockers
Insertion of shortcodes from other plugins
PHP code processing
Ad rotation (server-side and client-side – works with caching)
Desktop/mobile device detection (server-side and client-side – works with caching)
Black/White-list categories, tags, post IDs, urls, url parameters, referers
Simple troubleshooting with many debugging functions
Function to visualize inserted code blocks
Function to visualize available insertion positions
Function to visualize HTML tags