Title: Install Google Analytics code without plugin
Last modified: February 14, 2020

---

# Install Google Analytics code without plugin

 *  [Alwin](https://wordpress.org/support/users/wp-opti/)
 * (@wp-opti)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/install-google-analytics-code-without-plugin/)
 * I always used a WordPress plugin to add my GA to my WordPress websites. Now I
   want to add the code without the need of a plugin. I want to add two things to
   the default code:
 * – Increase the siteSpeedSampleRate to 50%
    – Anonymize IP adresses
 * So this is the code I have right now, and I like to know if I set this up correctly:
 *     ```
       <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>
       <script>
         window.dataLayer = window.dataLayer || [];
         function gtag(){dataLayer.push(arguments);}
         gtag('js', new Date());
   
           gtag('config', 'UA-XXXXXXXX-X', {'siteSpeedSampleRate': 50});
           gtag('config', '<GA_MEASUREMENT_ID>', { 'anonymize_ip': true });
   
       </script>
       ```
   
 * I don’t use the tagmanager, so maybe I can delete the line?
    `<script async src
   ="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>`
 * Thanks for your help 🙂
 * Alwin
    -  This topic was modified 6 years, 6 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
    -  This topic was modified 6 years, 6 months ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).
      Reason: Moved to Fixing WordPress, this is not an Everything else WordPress
      topic

Viewing 1 replies (of 1 total)

 *  Moderator [t-p](https://wordpress.org/support/users/t-p/)
 * (@t-p)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/install-google-analytics-code-without-plugin/#post-12437211)
 * Try reviewing this
    [https://www.wpbeginner.com/beginners-guide/how-to-install-google-analytics-in-wordpress/](https://www.wpbeginner.com/beginners-guide/how-to-install-google-analytics-in-wordpress/)
   [https://premium.wpmudev.org/blog/google-analytics-tracking-code-wordpress/](https://premium.wpmudev.org/blog/google-analytics-tracking-code-wordpress/)
    -  This reply was modified 6 years, 6 months ago by [t-p](https://wordpress.org/support/users/t-p/).

Viewing 1 replies (of 1 total)

The topic ‘Install Google Analytics code without plugin’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [t-p](https://wordpress.org/support/users/t-p/)
 * Last activity: [6 years, 6 months ago](https://wordpress.org/support/topic/install-google-analytics-code-without-plugin/#post-12437211)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
