How do I add Google Analytics to a WordPress website?

This article will show you how to set up Google Analytics on WordPress.

If you’re looking for a quicker and easier way of viewing your website’s metrics, you can add Google Analytics to WordPress, allowing you to manage your site and measure its performance from one handy place.

Simply choose one of the following methods below to find out how to include Google Analytics in WordPress:

Without a plugin

Please note: this process is recommended for advanced users as it involves accessing and changing your website’s coding.

Step 1 of 9

Start by logging in to your Google Analytics account.


Step 2 of 9

From there, select Admin in the left-hand menu.

Select Admin


Step 3 of 9

On the next page, select Tracking Info within the Property menu and then click Tracking Code.

Alternatively, if you’re using Google Analytics 4, select Data Streams within the Property menu and then choose your desired option from the provided list.

Select Data Streams


Step 4 of 9

You will now be shown your unique ID, along with a series of tag code. Copy or make a note of both these items.

Copy unique data


Step 5 of 9

Next, log in to your WordPress dashboard.


Step 6 of 9

From there, hover your cursor over Appearance in the left-hand menu and then select Theme file editor from the provided options.

Select Theme File Editor


Step 7 of 9

On the next page, select header.php within the Theme Files section.

Select Header


Step 8 of 9

You will now be shown a page full of code. Simply paste the tracking code that you copied earlier into this page.

If you’re not sure where to place your Google Analytics code, we recommend inserting it into Line 38.

Enter tracking code


Step 9 of 9

Once you’ve done this, click Update File to save your changes.
Update file


With a plugin

Step 1 of 7

Start by installing and activating the plugin MonsterInsights.


Step 2 of 7

You will now be taken to the main portal for MonsterInsights. From here, click Launch the Wizard to begin setting up the plugin.

Launch Wizard


Step 3 of 7

Follow the on-screen instructions and you will eventually be prompted with a message asking you to connect WordPress to Google Analytics. Click Connect MonsterInsights to continue.

Connect MonsterInsights


Step 4 of 7

You’ll now need to log in to your Google account. Simply enter your details and click Next.

Log into Google


Step 5 of 7

After you’ve done this, select your profile from the provided drop-down menu and then click Complete Connection.

Complete connection


Step 6 of 7

Your plugin will now begin authenticating. Once this has been completed, you’ll need to select which features you wish to enable for your site and click Continue.

Alternatively, you can click Skip for Now if you’d rather decide this later.

Select features


Step 7 of 7

On the next page, you’ll now see a confirmation message, stating that MonsterInsights has connected to your Google Analytics account.

View installation

You can now view your Google Analytics for your WordPress site by selecting Insights in the left-hand menu.

Select Insights