Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitLab with WP-CLI:
wp plugin install https://gitlab.com/markphahn/google-analytics-wordpress-plugin/-/archive/master/google-analytics-wordpress-plugin-master.zipNo built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.
Simple Google Analytics Plugin
So you want to add Google Analytics to your Wordpress site and don't want
it to get overwritten with the next update.
The quickest way is to create a simple plugin. This is that plugin.
Approach
The idea is to build a 20-30 line plugin which you manage. The plugin
is not very complicated and easy if you have coding skills.
My aproach works is you have access to the filesystem and can add the
plugin file to the Wordpress folder. (I could upskill this to be a
marketplace solution, but I don't want to ahve to create a admin UI.)
Step by Setp Directions
Google Analytics
Sign up for Google Analytics
Find the tracking code snippit. It somewhere under the
admin UI. It will look a lot like this:
Create the plugin file
In the directory wpcontent/plugins create a file for your plugin.
Name it with your initials followed by -google-analytics.php. In my
case my initials are MpH so I called the file mph-google-analytics.php.
The reason to pre-pend your initials is that the file name is the
identification for the plugin. As in global identification. If you choose
a filename that matches another plugin's name on the marketplace, you may
see notices tha