How to Add Google Analytics to WordPress Without a Plugin?

Google Analytics is a web analytics solution from Google and mostly free service that tracks the visitor’s reach on the website. Google acquired this service from Urchin in 2005. As webmaster and owner of the WordPress site, one always wish to include Google Analytics, for proper measurement of visitor’s metrics. In order to add Google Analytics to WordPress website without the plugin, we need three segments.

  • The first segment is all about creating a Google Analytics account.
  • The second segment is to find out the Google Analytics tracking code for your website.
  • The third segment is to add Google Analytics tracking code into the WordPress website through cpanel.

1.Create a Google Analytics account for your WordPress website:

  • Open the Google Analytics website. [https]://[]/[analytics]/
  • Use Google mail to log in to it.
  • Go to ADMIN inside Google Analytics.
  • You can open 100 accounts for sites inside Google Analytics.
  • Click on CREATE ACCOUNT.
  • You may choose from WEBSITE or MOBILE APP.
  • Here we are opening the account for the website so should choose WEBSITE.
  • In the ACCOUNTS NAME name, you’re my new account name.
  • In the SETTING UP YOUR PROPERTY the first part is WEBSITE NAME.
  • Write the name of your website there.
  • In the WEBSITE URL write the complete website URL.
  • In the INDUSTRY CATEGORY select one from which your website belongs to.
  • Then in the REPORTING TIME ZONE, first select your country and then provide country-specific time zone.
  • There some subset of it and you can select or not select as per your wish.
  • Then click on GET TRACKING ID to create Google Analytics Account for your website.

2. How to find the Google Analytics Tracking Code for Website:

  • Now, you opened Google Analytics for your website.
  • Log in to Google Analytics.
  • Go to SETTINGS.
  • Go to ADMIN.
  • Here you will find out three columns.
  • One is ACCOUNT, then PROPERTY and then VIEW.
  • Go to middle one namely, PROPERTY.
  • Then go to TRACKING INFO. Click on it.
  • Then click on TRACKING CODE. Click on it.
  • Here, you will find TRACKING ID beginning with UA- and then STATUS.
  • Then WEBSITE TRACKING you will find GLOBAL SITE TAG (gtag.js).
  • Copy that GLOBAL SITE TAG code entirely.
  • Keep it in safer place as in the next phase we will be pasting this in header.php of the active theme file.

3. How to add Google Analytics tracking code to the website:

  • Log in to cPanel.
  • Go to FILES and then FILE MANAGER. Click on it.
  • Go to WP-CONTENT.
  • Then THEMES and then choose ACTIVATE THEME.
  • First back up HEADER.PHP file to your local computer.
  • Then choose HEADER.PHP and EDIT and then click on EDIT again.
  • I am using the twentytwelve child theme.
  • It is better to use a child theme while performing any modification to file.
  • Search for </head> and just before it copies paste the entire code collected from Google Analytics tracking code in the earlier segment.
  • Then click on SAVE CHANGES to apply Google Analytics tracking code to your website.

Some precautions.

  • If you are using Google Analytics on your website then update the privacy policy of your website according to it.
  • When you edit the file through cPanel which is a secure method but still back up the same file to the computer for extra security.
  • Always use the Child Theme, for your website. It keeps the main theme secure and whenever anything goes wrong then you can revert to the original theme again.

Related Posts:


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.