So I have had a play with this. You can add the following type of Javacript as a function that can then be called on a click (for example if they click the accept cookies button). This will dynamically insert the tracking scripts from google analytics. You can then take this to do the same for any other thirdparty libs you are using. You would then want to probably create a cookie to track that they have accepted so you can just run the script straight away. I havent actually tried this with Google Analytics but I think it should work.
Add the following script to the bottom of your body.
const target = document.body;
const gascript = document.createElement("script");
gascript.src = "https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID";
const gascriptblock = document.createElement("script");
const inlineScript = document.createTextNode(`
window.dataLayer = window.dataLayer || ;
gtag('js', new Date());
Then you could add this function as an action on your button as a static event for example:
Hope that helps