How To Add Google Analytics In Your WordPress Site Without A Plugin

Google Analytics WordPress

Before proceeding with this tutorial please note that if you change or update your theme you will have to add the tracking code again.

Login to the Google Analytics website. If you do not have an account you will have to create one. You can also login with your existing Gmail account.

If you have multiple sites attached to your account, select the site which you wish to the add tracking code for. In the case below, click where it says “All Web Site Data“.

Google Analytics Dashboard

Once clicked it will open an expanded menu, select your site then click “Open“.

Google Analytics - Choose Site

Click the last item from the left menu, “Admin“.

Google Analytics Dashboard

From the “Admin” dashboard click “Tracking Info“.

Google Analytics Admin Dashboard

Here is the magical code that will keep track of your site’s visitors.

  • Click anywhere in the text box and it will automatically highlight all the code for you.
  • To copy, either click “Edit” from your browser’s top menu, then “Copy“, or ‘Cmd‘ + ‘C‘ (Mac), or ‘Ctrl‘ + ‘C‘ (PC) from your keyboard.
Get Google Analytics Tag

Now let’s head back to our WordPress dashboard. In the left menu, hover over “Appearance” then click on “Theme Editor“.

Wordpress Dashboard - Theme Editor

On the left, select “Theme Header (header.php)“.

WordPress - Theme Editor, edit header.php

Now paste the Google Analytics code just above the closing </head> tag by performing a ‘Ctrl‘ + ‘V‘ (PC) or ‘Cmd‘ + ‘V‘ (Mac) or ‘Edit‘ then ‘Paste‘ from top browser menu.

Past Google Analytics Code in Theme
Paste Google Analytics above closing </head> as indicated by blue arrow above.

You will now see the pasted code below between the blue lines.

Add gtag.js to WordPress theme
Pasted Google Analytics tracking code in header.php via Theme Editor.

Click “Update File” button at bottom.

That’s it! You are done. It may take a day or so for tracking to work.

One thought on “How To Add Google Analytics In Your WordPress Site Without A Plugin

Leave a Reply

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