I have a problem with the code, not with installing a plugin.
It’s not required, so I don’t know why I have to use one. Also, I’m stubborn ??
For other people with similar problem, here is the functions.php with properly functioning Google Analytics in header:
https://wklej.org/id/1410939/
Just put your ID instead of XX-XXXXXXXX-X.
For displaying it in the footer, just change wp_head to wp_footer.