function add_google_analytics() {
    echo "<script> // Dein Google Analytics-Code hier </script>";
}
add_action('wp_head', 'add_google_analytics');

The function add_google_analytics() inserts the Google Analytics tracking code into the <head>section of a WordPress website. The code is stored in a <script>tag defined in the function. The function is called by the hook wp_head which is called when the <head>section of the website. The Google Analytics tracking code must be manually inserted into the function before the function is implemented in the functions.phpfile of the WordPress website. To get the tracking code, you need to log into your Google Analytics account and copy the tracking code from the Tracking Info menu.