Tracking Signups with Woot Lights

 

[obsolete]

Since our public launch on February 2nd our signups have been steadily increasing. Last Wednesday we signed up a record 50+ free accounts in a single 24 hour period. We use a combination of Loggly itself, Google Analytics, LoopFuse and SalesForce to track our signups, but those data points aren’t readily accessible by the entire office. I thought it would be fun and informative to implement a more real-time monitoring system for our new friends.

Enter my Woot lights and a MP3 of the stock market bell.

The code for all this stuff is on Github . You’ll need to load up your Arduino with the serial.c file, which contains a simple serial protocol that brings a pin high on receiving a ‘Y’ and low on receiving a ‘N’. More information on talking to Arduinos with Pythonis here.

The ground wire and and the trigger pin (port 13) are at the top, but covered up in the diagram above. You’ll need a PNP transistor, readily available from Radio Shack, or Fry’s. You can also order them on Sparkfun, where you can get an Arduino if you don’t have one already.

The server code is pretty straightforward. It just sends a Y or N down the serial line to the Arduino. You can test by starting the server:

python arduinoserver.py &

Next, test the server by going to http://localhost:9090/ You should be able to turn the lights on and off from the page.

Now lets look at the facet call we’re making on Loggly:

# facet check for signups 2 minutes ago to 1 minute ago resp, content = h.request(“http://%s.loggly.com/api/facets/date/?q=’/thankyou/’&from=NOW-2MINUTE&until=NOW-1MINUTE&buckets=1″ % subdomain, “GET”, headers={‘content-type':’text/plain’} ) foo = simplejson.loads(content) free = foo[‘data’].items()[0][1]

The search we’re running looks for the landing page for signups, which in our case is called ‘thankyou’. We’re asking Loggly to give us data that came in from 2 minutes ago to 1 minute ago, and put that in a single bucket, or result. Here’s that result as returned from Loggly:

superman-2:logglywoot kord$ python signup.py 
{
    "gmt_offset": "-0800", 
    "data": {
        "2011-03-03T02:12:27.715Z": 1
    }, 
    "numFound": 1, 
    "context": {
        "rows": null, 
        "from": "NOW-2MINUTE", 
        "until": "NOW-1MINUTE", 
        "start": 0, 
        "query": "'/thankyou/'", 
        "order": "desc"
    }, 
    "gap": "+1MINUTES"
}

Be sure to check out the LogglyAPIdocumentation on our wiki. There are all sorts of interesting things you can build with them!

Woot on.


Share Your Thoughts

Top