This tutorial will explain how to include Google Analytics 4 (GA4), Google Tag Manager (GTM) and Microsoft Clarity into Drupal using the theme_preprocess_html() hook. This is a code-first method which provides developers full control over script placement and customization. GA4 is an event based tracking with more advanced tracking options and machine learning insight. GTM is third party tag management all in one place, while Clarity tracks session recordings & heatmaps data. Injecting the codes directly via theme reduce module dependency, improves website performance. Exact script loading eas...