to the tippy ↑

Google Analytics

google-analytics2

At Wistia, we love analytics. While ours are pretty sweet, there are lots of tools out there, like Google Analytics. While Wistia's analytics give you more in-depth information on video plays, putting basic 'video play' stats in Google Analytics can give you a better picture of your web visit metrics.

This guide is here to help you get started integrating Wistia video tracking with your Google Analytics account.

Google Analytics Lab

We realize that sometimes these things can get a bit complex, so to save you some time we built out the Google Analytics Labs. It actually does all of the stuff mentioned below for you! You can check it out here.

If you are still committed to doing it yourself, read on!

Before You Get Started

Make sure you have installed the Google Analytics tracking scripts. These are necessary for any custom tracking we do below.

If you'd like to save yourself a little time and effort, have a look at our Google Analytics Lab. It's designed to make adding the Google Analytics intrgration to your Wistia embeds super easy. All you need to do is setup the aforementioned Google Analytics tracking scripts, grab an embed and head over to the lab to configure it.

Modify Your Wistia Embed Codes

Integrating with Google Analytics is actually extremely simple thanks to the Embed Shepherd. All you need to do is paste this little snippet of code anywhere on your website, preferably right before the </body> tag.

You'll need to add this to every page that contains a video you want to track. Or better yet, if you have a layout file or a footer that's shared across pages, just put it in there and you'll be good to go!

playlist_api.js
1
2
3
4
5
6
7
8
9
10
11
12
<script src="http://fast.wistia.net/static/embed_shepherd-v1.js"></script>
<script>
  wistiaEmbeds.onFind(function(video){
    video.bind("play", function(){
      _gaq.push(['_trackEvent', 'Video', 'Play', video.name()]);
      return this.unbind;
    }).bind("end", function(){
      _gaq.push(['_trackEvent', 'Video', 'Complete', video.name()]);
      return this.unbind;
    });
  });
</script>

This code fires a 'Play' event to Google Analytics whenever a video on your website is played. It also fires a 'Complete' event when a viewer reaches the end of a video.

We only fire each of these events once per video per page load (that's what the return this.unbind is for). So if a viewer plays and pauses a video over and over again, we'll only send one play event to Google. Pretty cool.

You can extend what we've done here to pipe many more events to Google Analytics if you like. Take a look at the Player API to see what's possible.

Track viewing in Google Analytics Dashboard

Now that we have all the back-end coding out of the way, it's time to monitor how the videos are performing on your Google Analytics Dashboard.

The first step is to navigate to the Event Tracking section. Click the "Behavior" area of the left hand nav bar, and then select "Event Tracking". The Event Tracking section will show the total number of events, the average number of events per visit, and the Top Events. To see just the video events, select "Categories".


The "Categories" events will now contain a "Video" section, which you defined in the Javascript earlier. Click "video" to drill into the specific event descriptions.


The "Video" section page will show the total number of plays and the total number of complete plays, which we defined in separate Javascript functions earlier. To see the plays or completes for a specific video (if you have started tracking multiple videos through GA) click on "Play" or "Complete".


The final drill down shows what specific video titles (defined in the javascript function above) were played.

Using Wistia and Google Analytics is a good way to get all your top-level video analytics data in the same place you already get your other website tracking information.