Skip over navigation

Google Analytics

You can add Google Analytics to your site for free. Follow the steps below. If you run into any snags, e-mail roxen@princeton.edu for assistance. We're happy to help.

NOTE: Google Analytics is not part of Princeton's Google Account suite. You will need to get a separate account if you wish to use Analytics for your website.

If you want to learn more about Google Analytics, visit the University's Lynda.com training website (login required) and search for "Google Analytics Essential Training."

Step 1: Get a Google Account

If you already have a Google account, and if you would like to use it, you are welcome to do so. If you would like to create a new account for only this purpose, you can do so for free at https://www.google.com/accounts/NewAccount. You may be able to use your Princeton email address as the username for any new accounts.


Step 2: Get a Google Analytics Number (UA number)

Once you have the Google account that you would like to use, register for a free Google Analytics service at http://www.google.com/analytics.

Follow the instructions

If you are a new user to Google Analytics, you should follow their instructions titled "Get Started with Google Analytics".

Get Your Number

Your UA number will appear something like "UA-12345678-9." Copy this number.


Step 3: Add the UA Number to Your Site

Log in to the edit server for your site and enter the Content Editor (the file and folder view). Look for the variables.xsl file. The XSL template files should be listed near the bottom. If you do not have this file, please e-mail us at roxen@princeton.edu.

Edit contents, and add the following code:

<xsl:variable name="stat-id-string" select="'UA-12345678-9'" />

Change "UA-12345678-9" to your UA number. Keep the single quotes inside of the double quotes.

"</xsl:stylesheet>" needs to be the last line of code on that page, so place the stat-id-string variable above this final line.

Commit "variables.xsl," and wait for front end replication (up to 10 minutes). Confirm within your analytics account that Google Analytics is receiving data for your site.

If you would like our help with this step, we would be happy to assist you. Simply e-mail roxen@princeton.edu with your UA number and sitename, and we will add it for you.)

Important Note

Only the front end servers will be used to gather statistics for your site. Statistics are not taken from the edit servers. Thus, if you would like to see the JavaScript inserted into your site for Analytics purposes, you will need to look on your live site.