Coming soon: external link tracking (and more) in Plone with collective.googleanalytics

Matt Yoder here at Groundwire is brewing up a really nice new feature for his already-excellent Google Analytics integration for Plone, collective.googleanalytics: tracking of external links, file downloads and mailto: links via Google Analytics “event tracking.”

If you’re not already familiar with collective.googleanalytics, that’s OK — it’s still in beta. 🙂  But it’s definitely worth checking out.  Collective.googleanalytics builds on the basic Google Analytics integration capabilities that are built into Plone already.  By taking advantage of Google Analytics’ web services API, collective.googleanalytics pulls selected snippets of your live Google Analytics data back into your Plone site so that site managers get “in their face” analytics data as they are managing content.  We find this really useful with our busy nonprofit clients, who might otherwise not be paying as much attention to their analytics as they ought to.

As we’ve been exploring the intersection of Plone and Google Analytics, we’ve realized that there is a bunch of interesting data that Google Analytics doesn’t automatically capture because they don’t generate full-fledged pageviews for the basic Google Analytics javascript to detect.  For example, “out of the box” Google Analytics doesn’t track PDF or other binary file downloads, people clicking on outbound links, or clicks on non-http links like “mailto:”.  (This isn’t Plone’s fault, it’s a consequence of Google Analytics’ fundamental design architecture.)

However, Google does provide a powerful, flexible (and fairly new) Events Tracking feature that you can call to track interesting non-page-view events like these.    And that’s what Matt is taking advantage of in his upcoming release of collective.googleanalytics to increase the amount of data that Plone sends to Google Analytics.

The collective.googleanalytics control panel has now grown a new set of configuration options:

new google analytics settings

As you can see, you now have the option to enable or disable tracking of email (mailto:) links, external outbound links, and file downloads.  Even better, these extensions are pluggable, so that if your site needs to track more kinds of events, you can easily write small plugins and have them appear in this menu!  Check here for samples of plugins, which should be easy to adapt for your own needs.  Matt would love contributions of additional useful tracking plugins!

Once configured, results will start showing up in Google Analytics under Content>Event Tracking, like so:

collective.googleanalytics is in beta right now; we’re using it on and on a  few of our clients’ sites — to rave reviews thus far.   A “1.0 final” release should come sometime in the next few weeks. Matt’s new work on external link tracking is still in a branch, and will be merged soon.

Bonus points:

  • Matt’s new branch also branch generates the basic Google Analytics tracking javascript for you automatically using the profile you select in the tracking section of the configlet.  (No need to copy-and-paste the javascript snippet from Google anymore, like you do in out-of-the-box Plone.  That’s a nice convenience feature.)
  • All of these new features use the new asynchronous Analytics tracking API, which  should offer some performance benefits over the old blocking javascript, which could sometimes slow down your page loads.

If you’re a Plone developer or integrator, we’d love you to check out, kick the tires and offer feedback.   General comments here are great — we also have a bug tracker on for bug reports or feature requests.

5 thoughts on “Coming soon: external link tracking (and more) in Plone with collective.googleanalytics”

  1. Jon, Great stuff!
    I’m sure Matt has already considered something like this, but here’s some javascript code I used for a client a while back. It tracks outgoing links as a hit to a pseudo page page on your site, rather than an event. Submitted for what it’s worth…
    $(function() {
    // make external links open in a new window and trackable in Google Analytics
    .attr(‘target’, ‘_blank’)
    pageTracker._trackPageview(‘/outgoing/’+ $(this).attr(‘href’));

  2. Joel – Thanks!
    At the risk of speaking of things well beyond my actual knowledge, my understanding is that Matt considered doing “fake page views,” (which was the only way to do this kind of tracking until fairly recently), but decided instead to use the new Event Tracking API. This has several advantages, the biggest of which is that treating these events as page views actually skews your page view stats (e.g. an outbound link shouldn’t count as a page view). IOW, apparently Events are now considered the “best practice” way to do this kind of stuff. Give it a whirl and let us know what you think!

  3. is it possible to display somewhere on the site popular content based on google analytics? If not, is there a chance that it will be implemented?

  4. Irina-

    Great question! collective.googleanalytics doesn’t currently include any public-facing functionality like that, but it would be quite simple to implement. We don’t currently have plans to do so, because we’ve mainly been focused on making analytics more useful and accessible t to the site managers, but we’d welcome a contribution along these lines, this is a great idea!

  5. Jon, figured that event tracking must be newer. It definitely looks like a better way. The fake page views thing was a bit of a kludge. I’ll have a look at event tracking for next time. The rest of the jquery might still be useful.

Comments are closed.