24-hr offer! $50 discount on our Content SEO training bundle! Get it TODAY!

Tracking Outbound / Affiliate Links with getClicky

Clicky web analyticsI use Clicky for most of my day-to-day tracking and analysis, only using Google Analytics for the harder analyses. One of the things Clicky can do most wonderfully is track outbound clicks. There’s an issue however when you start routing your affiliate links through a script or on-site redirect. I redirect mine through /out/ here on yoast.com, but not all of the /out/ links need to be tracked. Let me show you how I do track the ones I need to track.

Update: I ended upon adding this functionality to my Clicky for WordPress plugin.

Forcing Clicky to track a link as outbound

First of all, you need to know that when you add a class clicky_log_outbound to a link, Clicky will track each click on that link as an outbound link. Now I always add a class track or aff to my affiliate links that I want to have tracked, for instance:

<a class="track" href="https://yoast.com/out/clicky/">Clicky</a>

Of course I could manually add the clicky_log_outbound class, but that’s just a tad bit too much work, especially as most of my links have been “classed” already and I might want to use this class for other stuff later on.

Now, I add a tiny filter function to my sites functions.php file, this searches for links with class aff or track and adds the clicky_log_outbound class:

function clicky_outbound_filter( $content ) {
	$content = preg_replace('/<a([^>]+)?class="(aff|track)"([^>]+)?>/',
		'<a\1class="\2 clicky_log_outbound"\3>', $content);
	return $content;

add_filter( 'the_content', 'clicky_outbound_filter', 10, 1 );

That’s it! Clicky will now track those links as outbound. Now let’s set such a link up as a goal.

Goal Tracking in Clicky

For goal tracking you need to have a premium (read, paid) Clicky account, but it’s well worth it. Setting up a goal is a piece of cake. You go to your site’s analytics and then to Goals, Setup. You’ll see this interface:

Clicky goal tracking

You simply name the action, set the goal URL to be your outbound URL, you could do /out/clicky/ or, when you sometimes forget the last slash, /out/clicky*. You can set up revenue and even a funnel, a required page before one can reach that goal.

Once you’ve done that, the goals will show, in realtime, in your Goals overview and in your “bigscreen” Clicky display.

More tracking power: campaigns

This feature becomes even more powerful when you combine it with another great feature of Clicky; campaign tracking. Clicky fully supports the _utm type variables Google Analytics uses, so you can track campaigns and terms within campaigns.

Even better SEO with Yoast SEO Premium!

  • Optimize your site for the right keywords for your users
  • Avoid dead links in your site
  • Get previews for sharing on Twitter and Facebook
  • Content quality and link suggestions as you write
More info

17 Responses to Tracking Outbound / Affiliate Links with getClicky

  1. Mike Kalam
    Mike Kalam  • 7 years ago

    Great tool I will definately share link with my developer…

    Here’s another interesting chart by Nick Bilton of NYT that visualizes the number of links on the homepages of popular websites.


  2. Smashious
    Smashious  • 7 years ago

    Thanks for sharing this. Will try it out.

  3. Max Pen
    Max Pen  • 7 years ago

    Again a nice share on a useful resource for bloggers.

  4. André Scholten
    André Scholten  • 7 years ago

    Did getClicky build in a timeout in the outbound link tracking script? Otherwise you’re missing some data ;)

  5. arafinshaon
    arafinshaon  • 7 years ago

    Hmm sounds cool! I’m gonna try this. Tnx

  6. Martyn
    Martyn  • 7 years ago

    Another great tip!

  7. Pass Matric
    Pass Matric  • 7 years ago

    Nice Tip Joost.

  8. Jessica Frankie
    Jessica Frankie  • 7 years ago

    I will try this out because I need it for several websites. Could I use GA instead? Which one is safer/easier to handle?

  9. afrocosmopolitan
    afrocosmopolitan  • 7 years ago

    Sounds interesting. Have to study it more to see the possility of implementing it.

  10. john
    john  • 7 years ago

    If Clicky has no advantage over GA why would you use it? I find GA simple and direct and for most newbies the filtering you do to the cord will be a jargon!

  11. zambanini
    zambanini  • 7 years ago

    how do you rewrite your affili urls to come to /out/ ?

    • Ian Anderson Gray
      Ian Anderson Gray  • 7 years ago

      Me also! I’ve always wondered how you do this. Do you do this manually, or do you have a script that rewrites urls to /out/ ? I’d love to know!

    • Joe Zepernick
      Joe Zepernick  • 7 years ago

      I’d also like to see what they’re using for this. I’m currently using a plugin called affiliate link cloaking but I’m not a fan of how it handles this at all..

  12. Fritz
    Fritz  • 7 years ago

    What if Clicky could be build in into “Redirection” Plugin of WordPress? Now that could be a real nice tool to work with… yep, loading those php-files right now… :)

  13. Josh Fialkoff
    Josh Fialkoff  • 7 years ago

    Nice post Joost.
    I still don’t see the advantage over Google Analytics. With your GA plugin on WordPress it’s easy to track outbound links and with the new realtime functionality on Google Analytics it looks like the features are comparable.

  14. Gijs Bos
    Gijs Bos  • 7 years ago

    Question: what is the benefit compared to Google’s Virtual Pageviews ( http://code.google.com/apis/analytics/docs/tracking/asyncMigrationExamples.html#VirtualPageviews ) ? The virtual Pageviews method seemingly has the benefit of being fully integrated with Adwords / Analytics.

  15. Rebekka Deforce
    Rebekka Deforce  • 7 years ago

    Sounds handy. I’m definitely going to try this. Thx for this tip Joost!