Configuring Google Analytics for Optimizely

This topic describes how to set up Google Analytics for Optimizely to instantly connect to the tracked data. You can also set up the add-on so that editors and marketers can follow the statistics on the dashboard for the entire website and in edit view for each individual page.

You can choose between the built-in options Classic Google Analytics or Google Universal Analytics when configuring the add-on. You can also add a custom script instead to support, for example, Google Tag Manager.

You have the following options to configure Google Analytics for Optimizely to analyze the statistics:

  • On the Google Analytics website by configuring your Google Analytics account.
  • In Optimizely admin view by configuring both the Configure Tracking and Configure Analytics Gadget tabs, and adding the gadget to the dashboard.

Note: Custom tracking scripts need to be tested in advance to verify that they work as intended.

Getting started

Get started with Google Analytics for Optimizely in the user interface as follows:

  1. From the top menu, access Google Analytics for Optimizely by selecting CMS > AdminConfig > Tool Settings > Google Analytics. The summary shows status about your current tracking and gadget settings.
  2. Set up tracking through the Google account and Tracking ID for your organization.
    • Already have an existing Google account. Use the Tracking ID for configuration in Optimizely CMS admin view.
    • Have no Google account. Create a Google account by registering your website at the Google Analytics website. Follow the instructions on the website to generate the tracking code containing a Tracking ID. Use the Tracking ID for configuration in Optimizely CMS admin view.

Configuring tracking

Configuring roles

The virtual roles GoogleAnalyticsReaders and GoogleAnalyticsAdministrators to authorize editors to the gadget and administrators to the admin view, are added to the website context (in the InitializationModules). These roles are mapped as follows:

var vrReposistory = VirtualRoleRepository<VirtualRoleProviderBase>.GetDefault();
EnsureMappedRoleExists(vrReposistory, "GoogleAnalyticsAdministrators", "WebAdmins, Administrators");
EnsureMappedRoleExists(vrReposistory, "GoogleAnalyticsReaders", "WebEditors, WebAdmins, Administrators");

You can exclude a group from the map of these roles by changing the options in EPiServerFramework.config > episerver.framework > virtualRoles > providers.

Note: You must manually declare these required roles and assign them to the approriate accounts for websites (such as QuickSilver) with a claims security provider (such as Federated Identity or AspNet Identity). 

Adding tracking on your website

On the Configure Tracking tab, you can control which tracking information about your visitors is sent to Google Analytics.

GoogleAnalyticsAdminView.png

Configure the tracking of your website as follows and save the settings:

  1. Select the Configure Tracking tab.
  2. Select one of the following about what you want to track:
    • Share tracking ID for all sites means that you track all websites using the same Tracking ID . All websites in an enterprise installation will use the same Tracking ID.
    • Use a unique tracking ID for each site means that you track each website specifically by using an unique Tracking ID for each website in an enterprise installation. You need to configure Tracking ID and settings on each site’s tab.
  3. In Tracking ID, connect your Tracking ID to your website (you can find it under your Google Analytics settings page). The Tracking ID has the format UA-#####-#.
  4. In Script options, select one of the following tracking methods:
    • Google Classic Analytics will generate snippets that uses the classic syntax corresponds to the ga.js library. You cannot modify the generated tracking script added to the pages header with this option.
    • Google Universal Analytics will generate snippets that uses the universal syntax corresponds to the analytics.js library. You cannot modify the generated tracking script added to the pages header with this option.
    • Custom Tracking Script will generate a custom tracking script code. Selecting this option will open a text area to enter the custom tracking script code. The custom script can include a {id} “tracking ID place holder” to be replaced by the value entered in the Tracking ID option. Example:
      <script source="ga.js?id={id}" ></script> will add the custom script to pages header, for example, <script source="ga.js?id=UA-52745929-1" ></script>.
  5. On the Domains tab, select one of the following options (to see how these options are generated in code, refer to Customize tracking and e-commerce):
    • A single domain. Track a single domain with the Tracking ID.
    • One domain with multiple subdomains. Track one domain with multiple subdomains with the Tracking ID.
    • Multiple top-level domains. Track multiple domains with the same Tracking ID.
  6. On the Roles tab, select one of the following options:
    • Track selected roles. Renders tracking only for users in the selected roles.
    • Track everything except for selected roles. Renders tracking for all visits except for visits by users with the selected roles.
  7. On the Links & Downloads tab, select one or several of the following options:
    • Track clicks on external links. Tracks clicks on external links. All links with a link “http” or “https” that is not the same domain are considered to be external links. By selecting Track clicks on external links as page views you can track external links and convert them to virtual links as page views on the site, starting with “/external/”.
    • Track clicks on e-mail links. Tracks clicks on e-mail links (containing mailto tags).
    • Track clicks on download links. Tracks clicks on file download links with the extensions defined in the pipe-separated list (|). The list of extensions is not case sensitive.
  8. On the Users & Interaction tab, select one or several of the following options:
    • Track logins. Tracks logins on the website as an event.
    • Track visitor groups. Tracks users who match a visitor group as an event. To make this work, the Statistics check box needs to be selected for the visitor groups on your website.
    • Track form postings. Tracks form postings as an event (XForms).
    • Track authors. Tracks a user creating a page as a custom property.

Note: Do not mix Ecommerce and Enhanced Ecommerce tracking on your pages. If you want to track e-commerce events, make sure your UA account has Ecommerce tracking enabled.

Connecting the gadget to Google Analytics

You can view the analytics on the dashboard by connecting the gadget to Google Analytics as follows:

  1. Select the Configure Analytics Gadget tab.
  2. Connect the Optimizely website with Google Analytics by clicking the Log in button.
  3. Select which user groups that are allowed to access the analytics.
  4. In Google Analytics Authentication, log in to the Google Analytics account with valid login credentials for your organization.
  5. Save the settings.
  6. Add the gadget to the dashboard and/or in the CMS edit view.

Related topics

Last updated: Nov 25, 2014