Title: Google Analytics code best practice
Last modified: July 17, 2022

---

# Google Analytics code best practice

 *  Resolved [unsustainable](https://wordpress.org/support/users/unsustainable/)
 * (@unsustainable)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/google-analytics-code-best-practice/)
 * Hi guys,
 * Looking for suggestions on the best way to add google analytics code, and how
   to set up Litespeed to increase page speed in regards to it.
 * I have 3 GA codes in my header (UA,GA4, and WebStories)
 * I’m failing CWV, and Lighthouse suggests that these codes are a large drain on
   inital load time.
 * I have Load JS Deferred set to “deferred”
 * Many thanks
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fgoogle-analytics-code-best-practice%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  [serpentdriver](https://wordpress.org/support/users/serpentdriver/)
 * (@serpentdriver)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/google-analytics-code-best-practice/#post-15837361)
 * There is nothing else you can do to improve loading GA scripts. Neither with 
   LiteSpeed cache plugin nor with any other method, but the problem is not GA Analytics
   itself. Each **external** request to load especially Javascript has affect on
   loading behaviour, so the best practice to improve is to remove GA. There are
   alternatives for GA. Check Matomo Analytics, a free open source analytics tool
   that is as powerfull as GA that you can host on own server.

Viewing 1 replies (of 1 total)

The topic ‘Google Analytics code best practice’ is closed to new replies.

 * ![](https://ps.w.org/litespeed-cache/assets/icon-256x256.png?rev=2554181)
 * [LiteSpeed Cache](https://wordpress.org/plugins/litespeed-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/litespeed-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/litespeed-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/litespeed-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/litespeed-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/litespeed-cache/reviews/)

## Tags

 * [js](https://wordpress.org/support/topic-tag/js/)

 * 2 replies
 * 2 participants
 * Last reply from: [serpentdriver](https://wordpress.org/support/users/serpentdriver/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/google-analytics-code-best-practice/#post-15837361)
 * Status: resolved