> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Google Analytics with WordPress

> Learn how to add Google Analytics to WordPress.

This article discusses several ways you can use Google Analytics with a WordPress site.

## Adding Google Analytics to WordPress

Google Analytics provides detailed statistics about visitor traffic to your site. To use Google Analytics with WordPress (or with any other type of site), you must first sign up for a Google Analytics account at [http://www.google.com/analytics](https://www.google.com/analytics) and obtain a unique Tracking ID.

After you have set up a Google Analytics account and have the Tracking ID for your site, you can configure it for WordPress. There are two ways to do this:

* Use a WordPress plugin.

* Edit the WordPress theme.

### Method #1: Use a plugin

There are numerous plugins that enable you to configure Google Analytics for a WordPress site, and they all function in essentially the same way—all you have to do is specify your Tracking ID, and the plugin takes care of the rest.

Here are some popular Google Analytics plugins for WordPress:

* [Google Analytics for WordPress](http://wordpress.org/extend/plugins/google-analytics-for-wordpress)

* [Google Analyticator](http://wordpress.org/plugins/google-analyticator)

* [Google Analytics](http://wordpress.org/plugins/googleanalytics/)

<Note>
  To view a complete list of Google Analytics plugins on the official WordPress site, please visit [http://wordpress.org/plugins/search.php?q=google+analytics](http://wordpress.org/plugins/search.php?q=google+analytics).
</Note>

### Method #2: Edit the theme

Plugins are convenient, but they also carry processing overhead with them that can affect site performance. If you prefer not to use a plugin, you can edit the WordPress theme directly to enable Google Analytics.

<Warning>
  **Important**

  One disadvantage of editing the theme directly is that if the theme is updated, the Google Analytics modifications are overwritten. To avoid this scenario, you should use a *child theme* instead of editing the base parent theme. For detailed information about how to set up a child theme in WordPress, please visit [http://codex.wordpress.org/Child\_Themes](http://codex.wordpress.org/Child_Themes).
</Warning>

To enable Google Analytics by editing the theme, follow these steps:

1. Log in to your Google Analytics account, click **Admin**, click **Tracking Info**, and then click **Tracking Code**. Copy the entire text in the tracking code box, including the starting `<script>` tag and the ending `</script>` tag.

2. Log in to WordPress as the administrator.

3. Under **Dashboard**, click **Appearance**, and then click **Editor**. The **Edit Themes** page appears.

4. Under **Templates**, click **Header (header.php)**.

5. Locate the ending `</head>` tag. Just above the `</head>` tag, paste the Tracking ID code snippet from Google Analytics that you obtained in step 1.
   > 🚧 Important
   >
   > Make sure you include the starting `<script>` tag and the ending `</script>` tag.

6. Click **Update File**. Google Analytics is now enabled for all pages on your WordPress site.
   > 📘 Note
   >
   > It can take up to 24 hours for Google Analytics to change its status from **Tracking Not Installed** to **Receiving Data**.

## More information

For more information about Google Analytics, please visit [http://www.google.com/analytics](https://www.google.com/analytics).
