Google Analytics Views


The Google Analytics Views can be used to manage the addition, editing, and deletion of Google Analytics views in OU Campus. The base filtering from OU Campus is specific to the HTTP Root as set in the site settings. In other words, some institutions set up "sites" within a subdirectory of the main domain for the school. If the main domain is, a site might be set up within the main account with the site name "alumni" and the HTTP Root as In this case, if the same default all data view is used from the Google Analytics account, the analytics displayed within the main site (HTTP Root is will also include the data for the site setup in the subdirectory.

The Google Analytics Views setup in OU Campus is account-bound, but includes a filter for the HTTP Root setting. So when viewing analytics via the alumni site, only the data relevant to the content subordinate to the site is shown, even when using that same default all data view from Google Analytics. A new view could be created and a filter added to exclude subdirectories with a specific string in order to exclude a subsite to the main domain. 

The Google Analytics Views screen includes the following features and functionality:

  • Lists the number of views that have been added to OU Campus
  • Filtering the list based on description
  • Adding new views
  • Sorting the views by the following columns: Available To and Description
  • The following options are also available for each view: Edit and Delete
  • One or more views can be selected for applying an action en masse. When more than one view is selected, the items can be deleted.

The following step-by-step procedures are included on this page:

Adding a New Google Analytics View in OU Campus

Basic Steps (without screenshots)

  1. Log into an account if necessary and click Accept. Confirmation of authorization is provided.
  2. From the Add Google Analytics View (Profile) modal, select one or more views to add.
  3. Use the Available To drop-down to assign an access group. The default is the (Administrators Only) system group.
  4. Click Save.

Once a view has been added, users can view analytics data using the Page Analytics Gadget or the Site Analytics Gadget.

Steps with Screenshots

  1. Log into an account if necessary.
  2. From the Request for Permission window, choose a different account from the drop-down, if necessary, and select Accept. It may also be necessary to provide a password for the account. This step authorizes access to the analytics account.

    Request for Permission: Choose Account
  3. From the Add Google Analytics View (Profile) modal, select one or more views to add by using the checkboxes.

    Add Google Analytics View
  4. Use the Available To drop-down in order to assign a different access group, if necessary. The view name, property name, and account name are all configured at Google.
  5. Click Save. The addition is confirmed.

Once a view has been added, users with the proper permissions can view analytics data using the Site Analytics Gadget or the Page Analytics Gadget.

Adding a Description

A description can be added after adding and saving a view.

  1. From the Google Analytics Views screen, hover over the row for the view and select Edit.
    Edit Google Analytics Views
  2. From the Edit Google Analytics View dialog, click in the Description field to add a description.

    Edit Google Analytics View Dialog
  3. Click Save.

Creating a New Property at Google Analytics 

  1. Log in to the Google Analytics account.
  2. Navigate to the Admin panel.
  3. Make sure that the correct account is selected.
  4. From the Property drop-down, choose Create New Property.
  5. Choose what to track: Website or Mobile app.
  6. Add a friendly name for the Website Name, as this will display as the property name in OU Campus.
  7. Add the URL for the site. Secure http protocol can be selected.
  8. Selecting an Industry Category is optional.
  9. Configure the time zone if necessary.
  10. Click Get Tracking ID.
  11. Copy the tracking code and, if necessary, save it to a text file.

Example Tracking Code

  (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','//','ga');
  ga('create', 'UA-94263206b-2', 'auto');
  ga('send', 'pageview');

Note that Google Analytics tracking can alternatively be implemented with a PHP file or an include file. For most sites, especially those in OU Campus with many pages, the script can be added as an include or within the XSL. Script should get added to the <headcode> node of a page, so that it is added before the close of the head of the document; for example, </head>.

Adding Tracking Code as an Include

  1. Copy the tracking code into a .inc file and upload the file to the /includes directory.
  2. Save the file and edit one or more XSLs as necessary to utilize the include file.

Example of Location in an HTML Page

<script type="text/javascript">
  (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','//','ga');
  ga('create', 'UA-94263206b-2', 'auto');
  ga('send', 'pageview');

Adding Tracking Code to the XSL

Note: Editing the XSL for a site can affect the entire site. Familiarity with the templating process and XML/XSL is required for editing the base implementation for a site. For tips on setting up a test environment *before* implementing live changes to an XSL, see:

Troubleshooting Techniques

If there is a <headcode> node, add the script within those tags so that the script can be included just before the closing </head> tag of an HTML page.

  1. View a page in code view and look for the XSL that is called by the pcf-stylesheet declaration. For example: <?pcf-stylesheet path="/_resources/xsl/default.xsl" extension="html"?>

    Note: Depending upon the implementation and the template, there may be more than one XSL used. If different page templates use different XSLs, but all call the common.xsl, then the code could be added in a common.xsl.
  2. Locate where the scripts are being added to the <head> tag.
  3. Drop the tracking code in as another script element.
  4. Save the XSL. It is not required to publish the XSL.

Creating a New Reporting View at Google Analytics

New views can be added at Google Analytics at any time for a property and will fall under the reporting of the JS code that has already been added to a site. 

  1. Log in to the Google Analytics account.
  2. Navigate to the Admin panel.

    Google Analytics Account Example
  3. Make sure that the correct account and property are selected if more than one is available.
  4. From the View drop-down, select Create New View.
  5. Use a meaningful name as this will be displayed in OU Campus and there may be many views from which to choose.

There are many, many different ways to configure the setup of a view at Google. These include filters, channels, segments, content groupings, and so on. The Support Site v10 topics about the Site Analytics Gadget, the Page Analytics Gadget, and the Analytics Data Groups provide more information about the reporting items that are included in OU Campus.