There is alot way yo put GA tracking code in your wordpress site, this snippet is how to add the tracking code into function.php file

function add_ga_tracking() {
 <!-- Global site tag (gtag.js) - Google Analytics -->
<script async src=""></script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-123456789-0');
add_action( 'wp_head', 'add_ga_tracking' );

Make sure you change UA code UA-123456789-0 into your code.