How to Add Google Analytics to WordPress Without a Plugin

,

To insert Google Analytics into WordPress we must start with two considerations:

  1. It is not always true that to insert new features into WordPress, you need a plugin or to expand the functions of our WordPress site.
  2. Everyone, or almost everyone, uses the Google Analytics service to monitor the traffic of their WordPress site or blog,  which is also free and allows you to monitor more than one website.

Naturally, you’ll need a Google account, so you’ll need to register and add your new WordPress site/blog to monitor. We can then have the tracking code in this account and insert it into every page of the site. The so-called “tracking code” allows Analytics to collect and process various visitor statistics.

Google Analytics in WordPress

There are several plugins for inserting this code, but we can do it with a simple solution that only requires a little programming knowledge.

Simply find the  functions.php file   in your WordPress main template folder and insert the following code:

<?php
add_action('wp_footer', 'ga');

function ga() { ?>
    // Enter your Google Analytics ID here
<?php } ?>

This snippet simply uses the WordPress  wp_footer action to add the Google Analytics ID , which must be inserted under the “//Enter your Google Analytics ID here” heading within the snippet. This will automatically insert it into all pages of your WordPress site. This simple operation will allow you to view all the statistics on your WordPress site/blog in a truly complete and comprehensive way by connecting to Google Analytics and logging into the previously created account.

© 2025 Notework Web – All rights reserved.