Google Analytics Primer: Campaigns, Events, and Virtual Pageviews
Campaigns
IntroductionGoogle Analytics (GA) gives you the ability to track how different communication channels drive traffic to a particular webpage within your website. Using GA Campaigns, you may gather statistics to reveal the ROI of different channels. For example, you may measure the effectiveness of print ads versus marketing emails, or you may compare billboard ads to web buttons, or a combination of any of those channels and more. Questions that GA Campaigns can help to answer include: How did the visitors get to my site? Which channel did they use? Which channel brought the most visitors? Which channel was the most profitable? Which channel had the highest bounce rate (visitors leaving after a single page visit)? Which channel had the best ROI for that marketing campaign? What had the worst? You may track any number of types of channels that produce visits to your website. For example, you may track web buttons, marketing emails, and purchased digital ads. In addition, you may also track channels such as print ads, billboards, brochures, and viewbooks.
The key to building an effective GA Campaign is to first devise a way to organize all of the different channels that you will use in the marketing campaign. After forming an organization scheme, you may then build individual GA Campaign URLs.
When creating an organization scheme, you will want to specify the following:
Website URL (required)—The web address (URL) of the webpage to which you will direct visitors coming from a communications channel (e.g., The IU Bloomington Office of Admissions has built campaigns for high school juniors that direct recipients to http://admit.indiana.edu/juniors/).
Campaign Name (required)—The category name that you would use to organize all campaign links (e.g., 2012‐junior‐campaign).
Campaign Source (required)—A name given to identify a particular channel (e.g., indy‐star, hobsons‐connect, iub‐gateway, etc.)
Campaign Content (recommended)—A label used to differentiate ads that share the same source. For example, you might use Campaign Content to differentiate ads deployed by Hobsons at different dates (e.g., email‐2012‐03‐27), or you may use it to track different intended audiences (e.g., parent‐email, student‐email).
It is good practice to build a scheme for each ad that you deploy. Doing so will help make creating Campaign URLs (covered in the next section) more efficient and effective.
Creating GA Campaign URLs
Once you have created an organization scheme for each of the campaign ads that you will deploy, the next step is to build GA Campaign URLs for each ad. Begin by opening the GA Campaign URL builder (http://support.google.com/analytics/bin/answer.py?hl=en&answer=1033867).
From the organization schemes that you created for each campaign ad (in the previous section), complete the GA Builder form. Click the button labeled Generate URL to create an individual campaign URL: The campaign URL will be very long. For example, here’s the URL for the campaign ad depicted above: http://admit.indiana.edu/juniors/?utm_source=hobsons- 2013&utm_medium=email&utm_content=mar-27-email&utm_campaign=2013-junior-spring-campaign
While a long URL like this will work for web buttons, links in emails, or other media where you can create links without revealing that links URL, it might not work well with print media. In that light, we suggest that you use URL shortening services, such as Go IU (http://go.iu.edu/) or bit.ly (http://bit.ly). If you register for a free account, bit.ly allows you to customize the shortened URL.
Viewing Campaign Data
To access your campaign data from within GA, navigate to the Campaign reports using the following path: Standard Reporting » Traffic Sources » Sources » Campaigns:
In the report, you will see a list of GA Campaigns. Click the campaign name for which you would like to see additional data:
The resulting campaign report will display Source/Medium data by default. You may display other data by changing the Primary Dimension or adding a Secondary Dimension:
Events
Introduction By default, Google Analytics does not track certain actions not associated, in particular, with visiting a web page. For example, downloading a PDF or Word document, playing a video, or forwarding through a slideshow are all types of actions that GA does not track by default. When it comes to reporting, events are bounce rate‐neutral by default. They neither elevate nor decrease pageviews (and, thus, have no effect on bounce rate). In addition, you cannot use events when defining a GA goal.For most uses, events should have an inward focus (inside your site). That is, use events to track actions that happen inside your site whose results keep the user in your site (e.g., clicking a link to advance a slide in a slideshow will not cause the user to exit your site). Event Code Despite the lack of GA’s ability to track such actions by default, you can still track such actions using GA Event Tracking. By adding a small amount of JavaScript to certain links, you “tell” GA to track interactions with that link. The general form of GA event tracking code looks like this:
<a href=“some_folder/any_file.pdf” onclick=“_gaq_push([‘_trackEvent’,
CATEGORY, ACTION, OPTIONAL_LABEL, OPTIONAL_VALUE]);”>Link Label</a>
Descriptions of event components: CATEGORY – A string value that specifies a way to group events into a meaningful reporting class. For example, you might want to specify a category for ‘application‐packet‐downloads.’ Use single quotation marks around the category name. ACTION – A string value that names the action users take when clicking a link. For example, when users click a link to download a PDF, you may want to specify an action similar to ‘pdf‐download.’ If the action starts a video, you may want to specify an action similar to ‘play‐video.’ Use single quotation marks around the action name. OPTIONAL_LABEL – An optional string value that gives you an additional field in which you can collect additional data about a specific link. For example, if you wanted to identify a link in a particular section of a page, you may want to use the label in a way similar to ‘costs‐fin‐aid‐page‐the‐basics‐section.’ Use single quotation marks around the action name. OPTIONAL_VALUE – An optional integer value that gives you an additional field in which you can assign a numeric value to a field. Reports will add that numeric value to a sum for field. For example, if you attach the value 3 to a link, and the users click the link 4 times, your reports will show a sum of 12. Businesses will use this value often if they assign dollar values to certain links. Since the value is of integer type, do not enclose the value in quotation marks. As an example, you might have a link for a PDF download that looks like this initially: <a href=“documents/pdfs/admission-packet/fin-aid-info-2010.pdf”>Download information on financial aid</a>
To add event tracking code, you might add code that looks like this:
<a href=“documents/pdfs/admission-packet/fin-aid-info-2010.pdf”
onclick=“_gaq_push([‘_trackEvent’, ‘2012-application-packet’,
‘download’, ‘financial-aid-pdf’]);”>Download information on financial
aid</a>
Viewing Event Data
In your Google Analytics profile, to view event data, navigate to the Events reports by using the following path: Standard Reporting » Content » Events:
Using the Top Events report (Standard Reporting » Content » Events » Top Events), you can view event details quite quickly for individual campaigns. In the Top Events report, find the campaign in which you are interested and click its link:
You should now see the event actions associated with the campaign. To view the event labels instead, click the link named “Event Label” located in the line named “Primary Dimension:”
Virtual Pageviews
Introduction Similar to events, you can also use virtual pageviews track certain actions not tracked normally by GA. GA practitioners tend to use virtual pageviews to focus on outgoing (external) links. For example, GA would track an outgoing (external) link as a site exit by default. In that case, an outbound link would be counted in a summary total of all site exits. There is not a way, short of using virtual pageviews or events, to track individual outbound links.Comparing GA Events with Virtual Pageviews
Although they are similar, virtual pageviews and events differ in significant ways. See the chart below to review those differences:
Event Tracking Virtual Pageview
Bounce Rate Reduced Bounce Rate Reduced Bounce Rate Page Views No increase on total pageviews Artificial increase on total
pageviews Detailed Tracking Tracks more details correlated to
actions
Limited information
Goals Not supported Supported
Limitations Up to 500 GATC requests per session Up to 500 GATC requests per session Taken from Google Analytics: Event Tracking vs Virtual Pageviews (http://www.webseoanalytics.com/blog/google‐analytics‐event‐tracking‐vs‐virtual‐pageviews/). A Note about Virtual Pageviews and Bounce Rate For all intents and purposes, a virtual pageview acts as if it were a regular pageview normally tracked by Google Analytics. That means that clicks on a link with virtual pageview tracking installed will inflate the pageview count and can, potentially, have an effect on site bounce rate. If you have a large number of virtual pageviews, you may want to apply a filter to a secondary GA profile to filter out virtual pageviews by virtual path (see below for information on creating virtual paths). Virtual Pageview Code In a similar manner to events, you can add a small amount of JavaScript to links in order to create a virtual pageview. The general form of GA virtual pageview code looks like this: <a href=“http://www.someexternalserver.edu/”
onclick=“_gaq_push(['_trackPageview',VIRTUAL-PATH]);”>Link Label</a>
For the value for the VIRTUAL-PATH, use a path that differs from folder paths used within your website. Additionally, use a path that maps to the purpose of your virtual pageview.
As an example, assume that you wanted to add a virtual page to the following outbound link:
<a href=“http://www.indiana.edu/~sfa/”>Learn more about financial aid options.</a>
Your virtual pageview code might look similar to the following:
<a href=“http://www.indiana.edu/~sfa/”
onclick=“_gaq_push(['_trackPageview',
'/virtual/outbound-links/homepage/osfa']);”>Learn more about financial aid options.</a>
Notice that the virtual path has single quotes around it. Quotes are required around virtual paths, since they are string values. Also notice how the virtual path is constructed. Just by looking at, you can tell it is an outbound link (‘…/outbound-links/…’), that the link itself is on the homepage
a more complex virtual path can provide a way around virtual pageviews’ limited tracking scope, compared to events. A good practice is to identify all virtual paths by starting their path the same way (e.g., “/virtual/…”). Doing so will make it easier to filter virtual pageviews in your GA reports. Viewing Virtual Pageview Data in Reports Since virtual pageviews behave like normal pageviews already tracked by GA, you can see them in any of your Content Reports (Standard Reporting » Content). To focus solely on virtual pageviews, you can use a quick report filter on most Content reports. The example below demonstrates the All Pages Report (Standard Reporting » Content » Site Content » All Pages):
To filter the report to show only your virtual pageviews, enter the beginning text of your virtual paths in the report filter textfield and click the magnifying glass to search:
Creating Custom URLs on an Apache Webserver
When using GA Campaigns, you might find that a campaign URL is a big too cumbersome for print advertisements. An example campaign URL might look like this: http://admit.indiana.edu/discover?utm_source=research-prospect-email&utm_medium=email&utm_campaign=admit-academic-options Obviously, the above URL is long and complicated, most likely resulting in abysmal open rates if printed on a postcard or other printed material. However, if your webserver runs Apache server software, you might be able to customize those URLs (mask them) with shorter, more amenable forms.
FAIR WARNING: To create a custom URL on an Apache system, you will need to modify a special file called the .htaccess file. The .htaccess file is a very powerful tool. However, as Uncle Ben advised Peter Parker (Spiderman), “With great power comes great responsibility.”
Modifying the .htaccess file with poorly‐formed code can cause great damage to your website, including making it completely inaccessible. Take steps to avoid making mistakes in your .htaccess file.
In short, always make a backup copy of the file before you edit and take care to follow the instructions below very closely!
Logging Into the Admissions Webserve Account
Before proceeding, you will need to make sure that you have an SSH program installed on your computer or that your computer supports SSH in some way. For Windows computers, you can download SSH clients via IU’s IUWare:
http://iuware.iu.edu/Windows/List/140
For most Macintosh computers, you can use SSH through Terminal, a built‐in Macintosh utility, under Applications » Utilities. The host name for Webserve, the University’s Web Service, is: webserve.iu.edu The username for the Admissions Webserve account is: iuadmit Before logging into the Admissions Webserve account, you will need to obtain the Webserve account’s password from your System Administrator. You will need the password every time you login to the Admissions Webserve account. On a Windows machine, use an SSH program, like PuTTY (see the link to IUWare, above) to access the Admissions Webserve account. In your SSH Program, enter the information from the textbox above, as needed. On a Macintosh machine, start Terminal, and then type the following: ssh iuadmit@webserve.iu.edu You may be asked if you want to trust the site. Answer yes. After you login, the screen should look similar to this:
Making a Backup Copy of Your .htacess File
Before editing your .htaccess file, you will need to make a backup copy of the file. First, you will need to switch to your www directory. Type cd www at the shell prompt and then press <ENTER> or <RETURN>:
If you typed everything correctly, Webserve’s shell will not give you any feedback other than a new prompt. If you made a mistake, you might see an error message printed to the screen.
At the new prompt, type cp .htaccess .htaccess.BKUP-MM-DD-YYYY (where MM-DD-YYYY is the current date) and press <ENTER> or <RETURN>:
Modifying the .htaccess File to Add a New Custom URL:
To begin modifying your .htacess file, you will need to use Webserve’s Nano editor. To start editing the .htaccess file, type nano .htaccess at your shell’s prompt and then press <ENTER> or <RETURN>:
In the Nano editor, use your arrow keys on your keyboard to arrow down to the area of the .htaccess file where you will find existing redirect code, just above the redirect permanent code. Be very careful not to edit any of the existing lines of code!
Before you begin adding new .htacess code, I recommend adding a comment with the name of the Google Analytics campaign as a reference: To add a comment, press <ENTER> or <RETURN> to start a new line and then type a pound character (#) before your comment:
Before you proceed, decide what custom URL you want to use. Here are a few important guidelines for creating custom URLs: Use only lowercase letters, digits, dashes, or underscores. Do not use spaces! You may also include forward slashes (/), if you want to represent a virtual “folder.” In your .htaccess file, when specify the custom URL, you begins after “http://admit.indiana.edu” part. That is, if you were creating a custom URL that looked like this: http://admit.indiana.edu/my-campaign You would only type /my-campaign in your .htacess file (the forward slash at the beginning is important!). VERY IMPORANT: Before continuing, double‐check that your chosen custom URL is not the URL of an existing page. That is try your custom URL (including the “http://admit.indiana.edu” part)in a web browser. If the URL is not being used by an existing page, you should get a “File Not Found (404)” error. The general code format that you will need to add to your .htacess file looks like this:
redirect Custom URL GA Campaign URL
For example, let’s assume that you are sending an email as part of a Hobson’s campaign. The GA Campaign URL loos like this: http://admit.indiana.edu/discover?utm_source=juniors-email-10-08-2012&utm_medium=email&utm_campaign=hobsons-fall-2012-campaign Instead of using the long URL above, you want to use the following URL: http://admit.indiana.edu/juniors-2012 First, test your URL in a web browser to make sure it is not already assigned to an existing site page. You should get a “File not found (404)” error. Next, remove the “http://admit.indiana.edu” portion of the URL. What remains it part of the code you will use when modifying the .htacess file: http://admit.indiana.edu/juniors-2012 In your .htacess file, on a new line, type the following (type 1 or spaces after redirect and /juniors-2012. Press <ENTER> or <RETURN> after typing the GA Campaign URL:
redirect /juniors-2012 http://admit.indiana.edu/? utm_source=juniors-email-10-08-2012&utm_medium= email&utm_campaign=hobsons-fall-2012-campaign These lines appear wrapped for readability. DO NOT press <ENTER> or <RETURN> until you reach the end of the GA Campaign URL!
Now imagine that you are sending two, similar emails to two different populations, one for juniors and one for sophomores. In that case, you might want to include a virtual “folder,” like this:
http://admit.indiana.edu/hobsons/juniors http://admit.indiana.edu/hobsons/sophomores
The .htacess code for these two rules would look similar to (GA Campaign URL removed for readability):
redirect hobsons/juniors [GA Campaign URL] redirect hobsons/sophomores [GA Campaign URL]
When adding the actual code in the Nano editor, you might notice a $ character appear at the end of lines. The $ character is how Nano indicates that the line of code continues past the set margins of the editor window. You can use your right or left arrow keys on your keyboard to see the rest of the line of code:
To save your file, press <CTRL> + o (the “WriteOut” command). When prompted with “File Name to Write,” press <ENTER> or <RETURN> to save the file as .htacess:
Look for the [ Wrote XXX lines ] message to make sure the .htacess file saved correctly:
Press <CTRL> + x to exit the Nano editor. To close the Webserve connection, type exit at the shell prompt and then press <ENTER> or <RETURN>: Test your new URL in a web browser to make sure it points to the correct GA campaign URL. In addition, be sure to check other areas of the site (especially the homepage) to make sure the changes you made to the .htacess file did not affect them.