First: find you tracking code in google Analytics
- goto Admin panel
- click “Tracnking info” under “Properly” block
- click “Tracking Info” and “Tracking Code”
- you will see you “Global Site Tag” on the right side.
- copy the html script !
Second: login you webserver and edit the php file
- cd into wordpress folder(wordpress/wp-content/themes/twentysixteen)
- vim header.php
- paste the First step code into <head>[put here]</head>
- save the file
Finally: visit you wordpress again the google analytics will work!
But you must edit each theme,if you change you theme.Edit the
wordpress/wp-content/themes/[twentysixteen,twentynineteen,twentyseventeen ]/header.php
I will try a more easy way to add google Analytics !