e

Like what you see? Let's talk about how we can help your business. Contact Us -->

Track Who’s Tracking You

Track Who’s Tracking You

Who's Following You on Social MediaTwitter and Facebook badges have become ubiquitous. You put them on each page of your site (at least most do), and you want people to follow you on Twitter and like you on Facebook. But how do you know if they are? If you’re using Google Analytics, it’s a piece of cake, even though it’s a bit of a hack.

Although Google Analytics doesn’t give you the ability to see what website drew your visitors off your site, if they leave by clicking a link on your site, you can track those clickthroughs by attaching a piece of Javascript to the link that creates a virtual pageview. A virtual page has all the properties of a regular page in your analytics and can even be assigned directories and subdirectories. And they show up in your Content report just like the real children.

Caveat: You can also track these clicks in Google Analytics using event tracking. Those in favor of that method say it’s better because creating virtual pageviews inflates the pageviews in your reports. However, I’ll show you how to filter these pageviews out of your analytics. The main reason people track pageviews is for ads; other than that, it’s a pretty junk metric in most cases. More importantly, I don’t like using events because you can’t set up an event as a goal (why, Google, whyyy?), and I like tracking these clickthroughs as micro conversions for websites alongside its other goals. I’ve done both and switched back to the virtual pageviews method, thankyouverymuch. But I’m open to hear salient arguments for why event tracking is better. (You won’t convince me, but you might have some luck with our readers. :))

Just Do It

Step 1: Come up with the structure for your virtual pageview. I like to start all of my virtual pageviews with /virtual/. This would be like the top-level directory. I’ve learned (the hard way, of course) that this makes it super easy to create an advanced segment for all your virtual pageviews. Then I break my pageviews into three categories: outbound, forms, and downloads and use that as the subdirectory of sorts. That’s just my personal preference. So in the case of tracking a link to a client’s Twitter page, for example, I’d use /virtual/outbound/. Then I use the name of the site as the last part of the page URI (or file if it’s a download or form if it’s a form). So my page would live out its virtual days as /virtual/outbound/twitter. If it were a “real” page, its actual Web address would be http://www.blueglass.com/virtual/outbound/twitter. (I use lower case to avoid URLs in cAmEl case. Haateit.)

Step 2: Find out if you’re using the traditional or asynchronous code on your site. To follow the path of least resistance, I just look at the source code in the browser to see if the tracking code has var pageTracker or var _gaq.push in it. If it uses the pageTracker code you have the traditional tracking code in place (old school). The asynchronous uses the push method for page tracking. (You should be migrating to the asynchronous, by the way.)

Step 3: Add the following script to the link you want to track. I’ll use Facebook this time: Traditional: <a href=”http://www.facebook.com/BlueGlassInc” onClick=”pageTracker._trackPageview(‘/virtual/outbound/facebook’);”>Facebook</a> Asynchronous: <a href=”http://www.facebook.com/BlueGlassInc” onClick=”_gaq.push(['_trackPageview', '/virtual/outbound/facebook']);”>Facebook</a> Note: If your pages have extensions (.html, .aspx, etc.), you may want to add the extensions to the end to keep the formatting consistent. This is purely a style preference if you’re given to fits of OCD. :)

Step 4: Get ready to add your goal. To do this, you have to have admin rights to the Google Analytics account. If you do, log in and click the Edit link to the far right of the profile you want to add your goal to.

Create Goals in Google Analytics

Step 5: This will take you to the Profile Settings page. In the Goals module, you’ll see four sets of goals. You can add up to five goals to each set. Click the Add goal link to get started.

Goal Interface in Google Analytics

Step 6: I’m not going to go through each setting as most are self-explanatory. So jumping ahead, since your goal is to register a pageview, you’ll choose the URL Destination option under Goal Type. Under Match Type, you have three options: Exact, Head, Regular Expression. I never use exact match because if any parameters are appended to your URL — from an RSS feed or social media or whatever — your goal won’t register. I usually use the Head Match option, which just means the URI has to contain whatever you put in there.

[Tip: You could always put this in the filter at the bottom of your content report to make sure the right page comes up if you're creating a goal for a real page.]

If my goal conversion (or a step in the goal funnel) could be one of two or more pages I use the Regular Expression Match option, but that’s outside the scope of this post. I’ll cover more sophisticated goal tracking in another blog post. In this case I’d just enter /virtual/outbound/facebook. I didn’t associate a goal value with this goal.

Configuring Goals in Google Analytics

Step 7: After you’ve had adequate time to gather some data, go into your analytics and check out your goals. You can look at your isolated goal tracking metrics under the Goals section or look at them in the context of other reports — most of the Visitors reports and all of Traffic Sources but none of the Content reports. Or you could create a segment that looks at, let’s just say, all visits that include a conversion for any of your social media follow goals. (Of course, you don’t know for sure they actually clicked the Follow or Like buttons when they get to your profile page, but this is Google Analtyics we’re talking about, not God.) You would set that up this way:

Advanced Segments in Google Analytics

Ninja Analytics Secret: If you want to see goal conversion rates for your landing pages, go to Visitors > Map Overlay and choose Landing Page from the Dimension drop-down. (It’s just to the right of the Detail Level options and above the report tabs.) This will replace the Countries with your landing pages. Then you can see conversions for each of your landing pages. Pretty sneaky, eh? If you have an ecommerce site, this is also the only way I know of to get revenue for each of your landing pages.

See Revenue for Landing Pages in Google Analytics

Step 8: If you want to filter your virtual pageviews out of your reports, create an advanced segment that filters those out. The easiest way would be to just click this link, and it will apply the one I created to your default profile. Well, it opens up the window with all the settings pre-loaded; all you have to do is it apply it to the profiles you create virtual pageviews for. You can also modify it however you want.) Then you’ll just want to choose your segment from the Advanced Segments drop-down, and your reports will be scrubbed of those virtual pageviews.

Filter Out Virtual Pageviews in Google Analytics

If you would like to learn more about Google Analytics check out some of our other posts that swing Google Analytics. And, of course, follow us on Twitter and/or hang with us on Facebook.

Want to Get Inside?

Become a BlueGlass Insider Today!

  • Be the first to know about BlueGlass events, meetups, and surprise releases. Before they’re made public…
  • Exclusive access to the latest tools, tips and must-read posts.From people who have been doing this for years…
  • Insider perspective on the latest trends in digital marketing. Info that you won’t get anywhere else…

Enter your email below to join for free!




Comments

  1. Ken Savage says:

    I don’t have any goal spots available! Ugggg

  2. Annie Cushing says:

    No problem, Ken. Just create a duplicate profile and start filling it up. You get 20 goals for each profile.

    Let me know if you need help setting that up. :)

  3. Tee says:

    Hi Annie, I was just researching this earlier today, and read through Google’s Event Tracking Guide. Their guide uses _trackEvent.

    What is the difference between _trackEvent and _trackPageview? And should I use _trackPageview instead of _trackEvent for tracking outbound link clicks?

    Thanks!

    • There are benefits to both. Event tracking preserves the integrity of your pageview data – and even bounce rates. But the biggest thing I don’t like about event tracking is you can’t track events as goals. I just found that when I used it, because it was separated from the rest of my goals, it was more out of sight, out of mind.

      However, the minute Google Analytics allows you to track events as goals, I will leave virtual pageviews in the dust.

  4. Unfortunately, due to the asynchronous nature of the new code the solution you provided wont track because a race condition exists.

    When you click the link, the request to Analytics and the request for the new page competes – usually, the new page wins.

    Ive tested this on my Rss feed and twitter links on my blog. So far, the only solution to this is through introducing some delay into the links. I got this solution from a site callled Gwo Tricks (sorry, id share a link but im writing this from my phone).

    • Annie Cushing says:

      That hasn’t been our experience, and we track all social media and RSS links. But it’s a pretty simple thing to programmatically add a delay if you need to. I had to do that once with cross-domain tracking.

  5. Rob K says:

    By the way, i believe Events impact the bouncerate metric because I’m tracking page load times through events and this affects my bounce rate – even though Google says its a non-interaction hit.

    Maybe it could be just my implementation..

    • Annie Cushing says:

      You can always filter these duplications out by creating advanced segments.

      • Rob says:

        Actually you can’t – Adv segments filters out visits.

        • If you’re tracking these as events, your pageviews (and thus bounce rate) aren’t going to be inflated, so no harm no foul. Even if you’re tracking page loads as events, you’re creating a separate bucket of events. That’s what makes events preferable over virtual pageviews if you don’t care about tracking goals.

  6. Rob: yes, tracking outbound links will definitely affect your bounce rate.
    But there is more:
    - The event might not be tracked if the outbound link is loading in the same window
    - What about people doing right-click/open in new window (or tab)
    - Do you really want to go through your site and manually add the onclick for all outbound links?

    Check out my blog post about all the things that were considered when I created _trackOutbound for gaAddons: http://blog.immeria.net/2010/11/gaaddons-outbound-links-tracking-with.html

    Stéphane

    • Annie Cushing says:

      No, of course you don’t. You only want to do it to links that support KPIs that impact your bottom line. For websites that are active in social media, tracking microconversions such as who’s clicking through to your social media profiles, is important.

      Most people use a template of some type, so as far as tracking those who follow you on social media (the point of this post), you’re only adding it to a few links in your template/theme.

      • Rob Kingston says:

        I agree – used only to track things you need to makes sense. If not, you can always filter pageviews out.

        Whether people click and open it in a new window shouldn’t matter – all you really need is to see the trends. Analytics is not 100% accurate itself, but it’s good enough to spot trends and use them to take action on.