Child Theme | Tag Manager

I am new to website development. I have switched my scripts over to the tag manager and everytime I update my divi theme it deletes all my scripts. I guess that is why we add child themes. So I have a child theme up and my css modifications are added to the child theme style.css sheet and that was pretty straight forward. But I am having a harder time finding information on how to modify the child theme functions.php file. I want to add my tag manager <header> and <body> scripts into the child theme functions.php file, so I don’t keep losing my Google Analytics,, and tag manager scripts. Like I said, I am very new to the game. Am I even saying this correctly? And if so, can someone walk me through the process of adding tag manager and other scripts to my child theme, so I can update a theme and not lose my work. I swear divi updates the dang thing daily.