Google Analytics
This document will help you get started using the College's Google Analytics account. The College has a single Google Analytics account that is used in nearly all of our Web sites. This allows for comprehensive Web reports to be generated along with drill-down capabilities to specific Web sites.
If you would like your Web site included in Google Analytics, please insert the following code into your Web site's footer or at the bottom of every page to be tracked. It should be in the HTML just above the closing </body> tag.
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4037316-1");
pageTracker._setDomainName("psu.edu");
pageTracker._initData();
pageTracker._trackPageview();
</script>
Once you add the code to your Web site's footer or in the template, your statistics will start to show up in the College's Google Analytics account the following day.
Tracking code for files
Please note that Google Analytics will not by default track file downloads. So if you had PDFs or other files on our Web site they will not be monitored for use. This is because Google Analytics works by code that is at the bottom of pages and files are standalone. You can get Google Analytics to monitor files, but it requires you to add some special code to each file link.
For example, to log every click on a particular link to agsci.psu.edu/downloads/map.pdf you would add the following onClick attribute to the link's <a> tag:
<a href="http://agsci.psu.edu/downloads/map.pdf" onClick="javascript: pageTracker._trackPageview('http://agsci.psu.edu/downloads/map.pdf'); ">
Report Access
You will first need a Google.com account, which will be associated with an email address of your choosing. If you already have a Google.com account or already set one up, please email webservices@ag.psu.edu with your address and requesting access to Google analytics.
Viewing your Google Analytics Reports
- Visit: http://google.com/analytics
- Click the "Access Analytics" blue button.
- Log in with your Google.com account
- You will have the choice of 2 reports, choose one:
- External traffic only - Displays only non-PSU Web visitors - remove faculty/staff/student traffic. This is usually more important since faculty and staff sometimes skew Web statistics and give you a false sense of traffic patterns.
- Internal and External traffic - Display all traffic regardless if it is internal.
- You are now viewing the dashboard for the entire College - all traffic regardless of Web site URL. This is not your Web traffic, but instead the entire College.
- To view traffic for a specific Web site click "Content" on the left menu.
- Click "Content Drilldown"
- You will now see the listing of the top Web site URLs in the College.
- To view traffic for a specific click the URL or use the "filter page" search box at the bottom of the list. If you are filtering down to a specific you only have to type in a portion of the URL. Example, type in "ento" into the filter box and click go, then click the URL.
- You are now viewing traffic specific to a URL.
- You have the following options to view your data:
- You can change the date ranges by clicking the dates on the top right of the screen.
- There are different "views" of the data including table, percentage, performance, and comparisons.
- You can change the "dimension" drop down window to view different types of data including: keyword, location, refer, network location, browser and more.
Note: When "drilling down" into your site's content, please verify you are looking at the correct URL. If you wanted to see reports for: http://ento.psu.edu/extension/factsheets/black-carpet-beetle, you would click ento.psu.edu > extension > factsheets > black-carpet-beetle.
Creating Custom Reports
If you are only interested in statistics for an exact Web site, following the steps above to drill-down to your site becomes a time consuming process. You can follow the steps below to create a custom report that is already focused on one or more URLs. In Google Analytics, you can create an "advanced segment" to narrow down a report to basically any criteria.
- Log into Google Analytics
- Click "Advanced Segments" under "My Customizations" on the left menu.
- Click "Create New Custom Segment" on the top right of the screen.
- In the "type to filter" search box on the left menu type in "hostname" as one word.
- Drag the green hostname box over to the center column and on top of the dotted box labeled "dimension or metric".
- Change the condition to "contains" in the drop down box.
- In the value box, type in your full URL of your web site minus any slashes, http://, www or anything else. Example: ento.psu.edu
- Down at the bottom of the form you need to give your new segment a name, for example call it "Entomology site traffic".
- Click the button "create segment" to the right of the name box.
You have now created a new segment, which will be available at any point in the future from only your account. This segment can be applied to your reports by following the instructions below.
Applying Advanced Segments
- Log into Google Analytics
- From any report or the Dashboard click down arrow in the drop down window next to "advanced segments" on the top right of the screen.
- By default "All Visits" will be checked, which is the default segment that shows all traffic and all sites. Under "Custom Segments" you will see the segments you created.
- If you wish to only view your segment, check it in the "Custom Segments" box and un-check "All Visits". If you leave "All Visits" checked, it will overlay the reports to allow comparisons.
- Once you have selected your segment and unchecked "All Visits" you can click "Apply" below the "Custom Segments" menu.
You are now viewing all of the reports that are narrowed to to only this specific segment or Web site. You can verify the segment is selected by looking above the graph on any report and it should say the name of the segment you created.

