"Manual" Google Analytics

Google Analytic plugins are known to slow down sites on Google Page Speed. This is even when the analytics.js is asynchronously downloaded. I want to keep a copy of analytics.js locally and add the Google Analytics Tag JavaScript code manually, as opposed to using a plugin.

It says " tag should be added near the top of the <head> tag and before any other script or CSS tags". Where would be the best place to store the Tag JavaScript code? On the Header as a Raw Code?

Many thanks in advance.

Hi @sgchan,

Thanks for reaching out.
To add the Custom JavaScript codes to the Header & Footer, please check out this article.
Please remember that we don’t offer any support for the custom codes or issues related to them.

Thanks

Thank you for your reply.

Noted about the support.

You are most welcome

Hi,

I struggle with this GA for so many days. I tried everything suggested. Cant see GA script code in source code output. Now I gonna bash using manual editing.

First of all may I suggest to make this GA enabling on X theme much easier.
Secondly, would it be possible do document how safely add script in footer or header.

Here is the code from theme editor. Where exactly I place GA code with the tag? thanks


<?php // ============================================================================= // FOOTER.PHP // ----------------------------------------------------------------------------- // The site footer. // ============================================================================= x_get_view( 'footer', 'base' );

Hi @VitaliKon,

To add the custom JavaScript code, I would suggest you use any plugins instead of modifying the main theme files. Please read this article on how you can add the custom JavaScript.
Please remember that we don’t offer any support for the custom codes or issues related to them.

The Google Analytics bundled plugin hasn’t been updated to work with the latest offering of Google Analytics. We are still working on the update, till then, you can use Google’s official WordPress plugin named Site Kit.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.