“Unique” Pageviews and Events Can Sound Like the Opposite of What They Mean

Unique Pageviewsview at full size

Unique pageviews represent the number of sessions during which the page was viewed at least once.

In Google Analytics, unique events and unique pageviews almost mean the opposite of what they sound like.

The unique events metric doesn’t indicate the number of unique times that an event occurred, but instead the the number of sessions during which this event occurred at least one time. Same thing for unique pageviews: the number of sessions during which the page was viewed at least one time.

It seems like the idea behind these metrics is that sometimes the fact that someone saw a page or completed an event at least once during a visit/session is more important than the number of times that this happened.

For instance, a page gets page value or counts towards a goal funnel the same way whether it was viewed one time or ten times prior to a goal or transaction. Similarly, if you set up an advanced segment based on page or event, the number of times that the page was viewed or event was completed during a session (or across all sessions if you set you advanced segment to User scope) doesn’t matter, as long as this happened at least once.

When you see unique as part of a metric name, think in terms of sessions.

Please share this post:
Facebook Twitter Plusone Linkedin Email

Video Play with Event Eliminates Bounce for the Session

A visitor begins a session on your home page, plays a video, and leaves. Does Google Analytics count that session as a bounce?

If you have used the default YouTube embed, the session will still count as a bounce. This is because Google Analytics records a visitor interaction only when it generates a hit.

If you have instead attached a Google Analytics event to a YouTube Player API embed, a video play will eliminate a bounce, since it will send a hit to the Google Analytics servers.

The same is true for a PDF download that you’re tracking as a virtual pageview, a Tweet link that you’re tracking as a social interaction, or a tracked Ecommerce transaction – all types of hits avoid a bounce for the session.

As a note, you can define an event as non-interaction. For instance, if a video begins automatically after 15 seconds on a page, you could still capture the video play as an event but opt to set the non-interaction parameter to true so that the video play in itself would not eliminate the bounce. For most events that you capture, however, a default interaction event is suitable.

In any case, it’s important to record all significant user interactions as some form of hit so your bounce rate and your overall Google Analytics data more accurately reflect user engagement.

Please share this post:
Facebook Twitter Plusone Linkedin Email

Round-Trip PDF Tracking with Virtual Pageviews and Campaign Tags

Pages reportview at full size

All virtual pageviews are integrated into the Pages report.

For the simple reason that PDFs do not contain the Google Analytics tracking code, links to PDFs do not, by default, generate data in Google Analytics.

So what we can do? We can generate a virtual pageview on the click action as in the code below, before the PDF even loads.

<a href="/catalog.pdf" onclick="ga('send','pageview','virtual-catalog-pdf')">Download our catalog</a>

In this way, we can generate virtual pageviews that will appear integrated into the Pages report and will act is the equivalent of a virtual page for all other purposes in Google Analytics, such as goals and funnel steps.

But how do we track links back to our website from a PDF? By default, a link back to your site from a PDF would count as direct traffic since there would be no referring website that GA could record. To make these clickbacks trackable, you can add campaign parameters, also called campaign “tags”, to your inbound links.

Please share this post:
Facebook Twitter Plusone Linkedin Email

Google Analytics “Hit”: Definition and Limits

Although pageviews are central to Google Analytics, the calculation of interaction metrics and limits in Google Analytics is based on a broader set of interactions.

A Google Analytics hit is defined as a pageview, a virtual pageview, an event, a social action, or an Ecommerce transaction. Unlike regular pageviews, the other types of interactions are not generated by the default Google Analytics tracking code but instead require special coding.

For calculating time metrics and bounce, Google Analytics treats all hits equally. For this reason, if a virtual pageview (from a PDF download, for example) or an event (from a video play) occurs during a single-page visit, that visit is not counted as a bounce (unless, in the case of the event, you have coded the event as non-interaction).

Google Analytics bases interaction limits on hits and not exclusively on pageviews. Google Analytics can capture up to 500 hits per visit and 10 million hits per month. (The monthly hit limit for Google Analytics Premium increases to 1 billion.)

Note that hit in Google Analytics differs from the general hit of Web server parlance, which instead refers to a request for any file from the Web server, such as HTML, CSS, JavaScript, or an image. (It also differs from the layperson’s usage of hit as a visit to your website.)

Although hit does not appear anywhere in the Google Analytics interface, it’s an important concept for Google Analytics practitioners.

Please share this post:
Facebook Twitter Plusone Linkedin Email

Use onmousedown JavaScript Listener for Events if onclick Doesn’t Work

Real-Time Events reportview at full size

Whichever JavaScript listener you use, you can check your event in the Real-Time reports.

If you’re trying to generate a Google Analytics event based on a click and onclick isn’t working, try onmousedown instead.

Let’s say that you want to track a click on the following mailto: link as a Google Analytics event:

<a href="mailto:[email protected]?subject=Demo%20Request">mailto: link</a>.

If you use the JavaScript onclick handler, make sure to test the event in multiple browsers, because if the “mouseup” part of the click is not recognized, onclick never fires:

<a onclick="ga('send', 'event', 'link', 'mailto', this.href);" href="mailto:[email protected]?subject=Demo%20Request">mailto: link</a>.

If onclick is proving unreliable, use onmousedown instead:

<a onmousedown="ga('send', 'event', 'link', 'mailto', this.href);" href="mailto:[email protected]?subject=Demo%20Request">mailto: link</a>.

If you’re using jQuery, you can similarly use the .mousedown() listener instead of .click().

Whichever option you choose to capture your events, you can test your events in the Real-Time reports.

Please share this post:
Facebook Twitter Plusone Linkedin Email

Generate Print Events with onafterprint JavaScript Handler

For visitors using Firefox or Internet Explorer, you can combine the built-in onafterprint JavaScript handler with Google Analytics _trackEvent code as below to record each time a Web page in printed:

<body onafterprint="_gaq.push(['_trackEvent','page','print', document.location.pathname+document.location.search])">

The specific parameters that you pass to _trackEvent are your decision, but you’d certainly want to record the URL of the page printed – either as the event label or possibly the event action. (In the example above, document.location.pathname is used to capture the part of the URL after the domain but before any question mark, and document.location.search is used to capture any question mark in the URL and the querystring that follows the question mark.)

Note that onafterprint is used within the <body> tag, so you’ll probably incorporate it into your page template (and not inject on a page-by-page basis).

As noted above, onafterprint is supported only in Firefox and IE, but since it’s probably safe to assume that Chrome and Safari users print pages at roughly the same rate as Firefox and IE users, you could easily apply advanced segments to calculate browser percentages and extrapolate print events for just Firefox and IE to print events for all browser types.

Please share this post:
Facebook Twitter Plusone Linkedin Email

To Track Embedded YouTube, Don’t Use the Default Embed

If you’ve embedded a YouTube video on a page of your website, it’s important to generate play and complete events within Google Analytics so you can know how many people are viewing the video, how many are making it to the end, and how these actions are influencing other behaviors such as goal completions and Ecommerce.

To capture YouTube events, you can use the YouTube Player API (instead of the default embed) as in the following code:


     <div id="player"></div>
     <script>
         var tag = document.createElement('script');
         tag.src = "http://www.youtube.com/player_api";
         var firstScriptTag = document.getElementsByTagName('script')[0];
         firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

         var player;
         var lastAction = '';
         function onYouTubePlayerAPIReady() {
             player = new YT.Player('player', {
                 playerVars: {
                     modestbranding: true,
                     theme: 'light',
                     rel: 0
                 },
                 height: '360',
                 width: '480',
                 videoId: '4GhUtN4Mlr0',
                 events: {
                     'onStateChange': onPlayerStateChange
                 }
             });
         }
 		
		function onPlayerStateChange(event) {
             switch (event.data) {
                 case YT.PlayerState.PLAYING:
                     //_gaq.push(['_trackEvent', 'video', 'started', player.getVideoUrl()]);
                     _gaq.push(['_trackEvent', 'video', 'started', 'overview']);
                     break;
                 case YT.PlayerState.ENDED:
                     _gaq.push(['_trackEvent', 'video', 'completed', 'overview']);
                     break;
                 case YT.PlayerState.PAUSED:
                     if (lastAction != 'paused') {
                         _gaq.push(['_trackEvent', 'video', 'paused', 'overview']);
                     } else {
                         lastAction = 'paused';
                     }
                     break;
             }
         }
	</script>

Note that when using the YouTube Player API, you can still take advantage of customized settings by specifying PlayerVars as above. (Importantly, the rel=0 prevents related videos from appearing after your own has completed.)

In a previous post, we also dicussed Google Analytics event for embedded Wistia video.

Please share this post:
Facebook Twitter Plusone Linkedin Email

For Steps in a Goal Funnel, Use Virtual Pageviews Instead of Events

Virtual pageview as a funnel stepview at full size

Virtual pageviews can serve as steps in a goal funnel, but events cannot.

Yesterday’s post discussed one significant difference between events and virtual pageviews: events appear in separate reports.

While separate reports can be an advantage in many cases, a potential disadvantage of events is that they cannot be used as steps in a goal funnel.

For instance, if you defined a file download or a video play as an event, you could certainly define goals based on these events, but the events could not serve as steps in a funnel that led to a Destination URL goal.

If a user action needs to be incorporated into a goal funnel, you therefore must set up a corresponding virtual pageview instead of an event.

Please share this post:
Facebook Twitter Plusone Linkedin Email

Virtual Pageviews Appear in Site Content Reports; Events Appear in Their Own Reports

Events reportview at full size

Events appear in dedicated reports.

For capturing user activity that does not generate a regular pageview, Google Analytics provides two options: events or virtual pageviews.

Of the many factors to consider when deciding between events or virtual pageviews, one of the most significant is that events appear in separate, dedicated Events reports, while virtual pageviews are integrated with regular pageviews in the Site Content reports.

For this reason, you may want to opt for a virtual pageview when the user activity is more akin to a regular pageview, such as opening a PDF. Similarly, you may want to go with an event for a user action, such as the completion of a video, that is less comparable to a regular pageview.

We’ll further compare events and virtual pageviews in an upcoming post.

Please share this post:
Facebook Twitter Plusone Linkedin Email

Advanced Segment for Visits with Live Chat

Advanced segment for live chatview at full size

In your conversion reports and most other Google Analytics reports, you can apply an advanced segment based on live chat.

Yesterday’s post discussed how to create a Google Analtyics event for clicks on live chat. With the event captured, we can see how many visitors are using live chat, but we can also see how live chat engagement corresponds with other behaviors, such as goal completion.

Assuming the you have used “livechat” as your event category, you can define two advanced segments as follows:

Advanced segment with live chat:
Include – Event Category – Containing – livechat

Advanced segment with live chat:
Exclude – Event Category – Containing – livechat

In the example screen shot, we can see that visitors who click live chat are three times more likely to convert. While it’s possible that the typical live chatter was already more committed to the conversion activity and would have converted at a higher rate even without live chat, the higher conversion rate observed for the live chat segment might indicate that you may at least need to make live chat more prominent on your pages to see if that increases overall conversions.

Please share this post:
Facebook Twitter Plusone Linkedin Email