TechBrew

Informative geekery on software and technology

Pipes Hack: Add a secret hit counter to your Yahoo Pipe

February 22nd, 2007 by Mark Woodman

Fault tolerance is a great thing, especially when you can take advantage of it to use a system in ways the creator didn’t intend.

Yahoo Pipes has a Fetch source module that allows you to specify multiple RSS/Atom feed URLs from which it will pull content. If one of those URLs doesn’t return a valid feed, it will simply be ignored. The fact that hitting that URL may have triggered something of significance… Pipes doesn’t know and doesn’t care.

Pipe HackHere’s the fun part: You can exploit that fault tolerance to put in URLs that activate hit counters, stats monitoring, or (if you’re evil and have an insanely popular pipe) a denial of service attack. Okay, maybe that last one isn’t “fun.” Forget I mentioned it.

I’d Hit That.

Just to be sure this scheme works, I decided to try it with a simple hit counter service, like the one at StatCounter. Here’s how to do it for yourself:

1. Sign up for a StatCounter account (it’s free) and set up a new project for your Pipe.

2. Follow the “install code” link to walk through a wizard that will set up your counter.

  • Choose “Invisible Counter”, then “No Frames”, then “HTML-Only Counter”, then “Default Install Guide”.
  • At the end you’ll then get an HTML snippet for your counter.
  • Grab the entire URL from the image src listed in the snippet. For example, “http://c22.statcounter.com/counter.php?sc_project?…”

Each time the image URL is requested by your browser, StatCounter registers a page hit. But it doesn’t have to be a browser… anything that uses HTTP GET on the URL will also increment the count. Like, say, the Pipes engine. (Muahaha.)

Hacked Pipe3. Create a Yahoo Pipe, and drop a Fetch module into the workspace. Use the [+] button on the module to add a second URL. Put in a legitimate feed URL in the first slot, and the hit counter image URL in the second slot.

4. Connect the Fetch module to whatever else you need to use in your Pipeline.

You’re done. Every time the Pipe refreshes the legitimate feed, it requests the hit counter image URL as well. The response isn’t an RSS feed, so Pipes ignores it and continues processing the real stuff.

You can now use your StatCounter account to see how often the Pipe is being used.

Proof of Concept

Stats GraphHere’s an example Pipe with a Hit Counter (using the TechBrew.net feed, of course), and here are the hit counter stats.

If you come up with a variation on this that does something interesting, drop me a comment and let me know. Have fun!

Trackback URI | Tags: How-To

7 responses so far ↓

  • 1 Azzam // Feb 22, 2007 at 12:42 pm

    Well done.

    I like this feature and will write up on a blog about it.
    This is a great feature to monitor the statistic through pipe feeds. I just created a module for Joomla based on yahoo pipes and will include this stats feature. Thanks.

  • 2 Azzam // Feb 22, 2007 at 12:43 pm

    I think you have to run over exactly how to accomplish this feature.
    i do not think I have grasped it fully.

  • 3 Mark Woodman // Feb 22, 2007 at 1:02 pm

    I updated it to be more explicit. Hope that helps!

  • 4 Azzam // Feb 22, 2007 at 1:17 pm

    Brilliant, thanks for the speedy response.
    Definitely will provide full credits to this blog for the stats solution.
    Incidentally, does this stat server restrict it to 100 unless you upgrade the service? If so any idea of an alternative.

  • 5 Mark Woodman // Feb 22, 2007 at 1:20 pm

    StatCounter is frankly one of the best I know of. You can google around for “free stat counter”. If you find something useful, drop a comment here.

  • 6 Azzam // Feb 22, 2007 at 1:23 pm

    Will this also work if you use the URLBuilder and not the fetch.
    Or if I put the stats in the the fetch module and connect the URLBuilder to the fetch module and then the pipe output

  • 7 Jenni // Mar 2, 2007 at 6:30 am

    Hi guys,

    Just to let you know – the StatCounter free account offers LIFETIME summary stats, together with detailed stats on your last 100 pageloads. Also, you can download your logs at any time too!

    Thanks for your support.

    Jenni
    StatCounter Team

Leave a Comment