What is the best practice for integrating Google Analytics tracking code into a website's menu file in PHP?

To integrate Google Analytics tracking code into a website's menu file in PHP, the best practice is to add the tracking code to the footer of the menu file so that it loads on every page of the website. This ensures that all page views are tracked accurately.

<?php
// Google Analytics tracking code
?>
<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_GA_TRACKING_ID"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'YOUR_GA_TRACKING_ID');
</script>