Hi there,
Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.
Please add following code in child theme’s functions.php file :
function third_party_tracking_code() { ?>
<script>
// Third party tracking code.
</script>
<?php }
add_action( 'wp_head', 'third_party_tracking_code' );
Hope it helps.