WordPress Google Analytics plugin code

This page was created for the YouTube tutorial video below. Use the following code, replace line 15 with your Google Tag and save the file as analytics.php:

<?php
/*
Plugin Name: My Google Analytics plugin
Description: My Google Analytics plugin
Author: Wouter Postma
Author URI: https://wouterpostma.nl/
Text Domain: google-analytics-plugin
Version: 1
*/


add_action('wp_head', 'wp_googleanalyticscode');
function wp_googleanalyticscode() { ?>
 
/*** REMOVE THIS AND REPLACE IT WITH YOUR GOOGLE ANALYTICS TAG ***/
 
<?php } ?>

https://www.youtube.com/watch?v=t7CX2JYcLnY