---
title: "Enabling Google Analytics support"
date: "2015-04-27"
category: "web-content"
slug: "enabling-google-analytics-support"
---

## Overview

[Google Analytics](http://google.com/analytics) is a free web analytics service from Google that provides SEO recommendations and live site traffic data.

![Sample Google Analytics dashboard](kb-image:rwd-dashboard.png)
*Sample Google Analytics dashboard*

## Setup Instructions

Google Analytics can be enabled on newer [[determining-platform-version]] using two lines in a [[htaccess-guide]].

1. Visit [Google Analytics](http://google.com/analytics) and create a [profile](https://support.google.com/analytics/answer/1009694?hl=en) for your domain.
   - Once the profile is created, you will see sample tracking code:

        <script>
         (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
         (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1\*new Date();a=s.createElement(o),
         m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
         })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
        ga('create', 'UA-99999000-1', 'auto');
         ga('send', 'pageview');
        </script>

   - Note your **account number** (format: `UA-XXXXXXXX-X`).
   - You do not need to add this code manually. It will be injected automatically via [mod\_pagespeed](https://developers.google.com/speed/pagespeed/module) in the next step.

2. Create a `.htaccess` file (if one does not already exist) in the [[where-is-site-content-served-from]] for your domain.

3. Add the following lines:
   ```
   ModPagespeedEnableFilters insert_ga
   ModPagespeedAnalyticsID UA-XXXXXXXX-X
   ```
   Replace `UA-XXXXXXXX-X` with your actual account number from step 1.

4. Wait 24 hours for statistics to begin appearing in your [Google Analytics](http://google.com/analytics) dashboard.
