I ran an SEO audit on my WP site and one of the recommendations was to "Implement an analytics tracking tool" so I figure instead of just adding any old plugin or adding the code to the page I would ask in terms of SEO and optimization, what is the best way to add google analytics to my WP site? If there is something better than Google Analytics I am open to ideas. I use WPRocket and I was thinking of going that route. Thanks in advance!
1 Answer
Try reading https://www.wpbeginner.com/beginners-guide/how-to-install-google-analytics-in-wordpress/#installga-wptheme for steps on how to install in WP without using a plugin. If you have a child theme, it is much better than using a plugin. Note the link is assuming you don't have a child theme, hence their recommendation to not use the method.
Also, since you're using WP Rocket, WPR don't expect WPR's local caching of the GA tags to work using the code that Google currently generates. Not a big deal, but you don't want to waste your energy trying to make something work, that must be coded differently.
Keep in mind that the more GA triggers you add, the slower your pages will load. So, if you're trying to keep your page speed super fast, make sure you limit GA triggers to only one's you are sure you need.
-
I get it, i like the functions.php option as I already added some custom code to it, but before I chose this option, is there any downside to letting it get added to all pages? I have not used GA in a while so if I do add it to functions and its on each page, does GA show the hit came from this part of the side? Commented Oct 6, 2020 at 19:46
-
@SimpliFixed, I think you're asking if GA shows the hit comes from specific pages??? If so, then the answer is yes. You can go to Behavior>Events to see what pages had what events triggered.– TreborCommented Oct 7, 2020 at 3:10