On September 14th, 2017, we published revised versions of our Privacy Policy, Terms of Service and Website Use Policy and published a Cookie Policy. Your continued use of Lynda.com means you agree to these revised documents, so please take a few minutes to read and understand them.

Learn it fast with expert-taught software and skills training at lynda.com. Start your free trial

By Chelsea Adams |

How to Install Google Analytics to WordPress in 5 Minutes

Install Google Analytics into WordPress in 5 minutes

If you can copy and paste text, you can install Google Analytics to WordPress. All you need is an established self-hosted WordPress.org website or blog, a Google Analytics account, and five minutes or less.

Note: You can only install Google Analytics on self-hosted WordPress.org sites and blogs. WordPress-hosted WordPress.com blogs won’t let you alter your header file or otherwise make low-level changes to your website infrastructure.

If you first need help setting up WordPress or your Google Analytics account, check out these videos on lynda.com:

Google Analytics Fundamentals: Setting up an account  (members only) • Installing and Running WordPress: Shared hosting (members only)

It’s just 11 easy steps

To add Google Analytics to your WordPress website, all you need to do is add a snippet of code to the header file of your WordPress website.

Follow these 11 steps:

1. Sign in to your Google Analytics account.

2. Navigate to the Admin section of your account by clicking Admin in the upper right of the screen, near the Help option.


3. Within your Google Analytics Administration view, you’ll see three columns: Account, Property, and View. Under the center column, Property, click Tracking Info. (Note: “Property” stands for web property. Unsure about what this means or the hierarchy of WordPress accounts? Watch our How Google Analytics accounts, properties, and views are structuredvideo.)


4. If clicking Tracking Info reveals five sub options, click Tracking Code.

5. You should now see your Google Analytics JavaScript (ga.js) tracking code, as below. Copy this code.


6. Log in to your WordPress account.

7. In the left-hand column of your WordPress Dashboard, hover your mouse over the Appearance panel to see the Appearance panel menu suboptions and choose Editor.


8. Now you’ll see your WordPress template files. Go to the right column and locate your header.php file. Click the header.php file to edit it.

9. Scroll through the .php file looking for the closing head tag, which looks like this: .

You can also do a search for using Command+F on a Mac or Control+F on a Windows PC.


10. Paste your Google Analytics ga.js code into this file right before the tag. So, in your .php header file you will see the following:



Paste your Google Analytics ga.js code between and.

11. Click Update File to save your changes—and you’re done!

Want to double-check?

If you’re the type who has to see it to believe it, you can confirm that Google Analytics is installed on every page of your website simply by navigating to the page in question and viewing the source code (right-click anywhere on the page and choose View Source Code).

Viewing the page source code, you should see your ga.js code right above the closing header tag () on every page.

To learn more about Google Analytics and WordPress, visit the lynda.com training library where you will find many more Google Analytics video tutorials and WordPress video tutorials.

Tags: , , , , , ,

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.