Integrate Google Event Tracking with JavaScript

This post discusses easy ways to integrate Google Analytics Event Tracking in your website. Event Tracking is a tool that broadens your ability to track user interaction with your website. Prior to event tracking, using Google Analytics gave you rich information about your page views. With Event Tracking you now have a wealth of information about usage on your non-page reloading events such as AJAX calls, hover events, mouseovers -- anything you would like to define and track. (Just make sure you have an account first).

It's dead simple and, after setup, takes a one-line call to a JavaScript method supplied by Google:

pageTracker._trackEvent(category, action, opt_label, opt_value);

You just have to get the right arguments to that method, so you know what you're tracking. In the Google tutorial the example is predicated around sending the arguments to the _trackEvent method inline on an onclick event. Instead of doing that, which will create redundant script tags in our views, let's label our markup in such a way that we can grab a collection of trackable elements via JavaScript and submit them automatically, on a click (or other) event.

Read the rest of this post »

Integrating the MIT / SIMILE timeline with Rails

This is a brief entry on how to populate the MIT / SIMILE timeline with dynamic data culled from a Rails application via a controller action that returns JSON. There is a plenty of existing solid information on the timeline itself, as well as a tutorial on integrating it with Rails and one focused on a simple html implementation. All these sources are clearly written and give basic usage tips. I recommend them and will not duplicate them here.

However, none of the sources demonstrated how to get dynamic data into the timeline via URL (they focused instead on creating the JSON / XML inline in the view via iterating through collections, or having it pre-existing as an external text file), I'm adding that information here in the hopes that someone else building in Rails finds it helpful.

Read the rest of this post »

Multiple File Upload using SWFUpload on Rails. Part II

This part of the tutorial covers getting the files that you select via your swfupload setup to upload into your Rails application. Part I covers the setup: getting the external libraries, markup, and JavaScript all in place. You can find that here. This tutorial assumes you are using attachment_fu. The Flash / Rails principles would be the same if you are using Paperclip, but the syntax for the upload itself would vary. However, since the main sticking point is the fact that Flash doesn't send the session_id to Rails when it posts data, thereby denying Rails access to current_user or a valid session, it is my hope that this article will be helpful regardless of which attachment plugin you are using.

Read the rest of this post »

Getting Started with Multiple File Upload using SWFUpload on Rails. Part I

There seemed to be enough confusion about this that I decided to document it in the hopes of helping someone else out moving forward. This post will be in a couple of parts. The first part addresses the now seemingly obvious step-by-step of getting the markup and JS laid in correctly so you can trigger the file upload dialog box using swfupload. The next episode will show getting the uploads into your application.

The Goal

Integrate the swfupload multiple file upload into a Rails application. Getting Started First of all, the current location for the swfobject code is at googlecode. For this post I used the most recent version, 2.2 Beta 5. 

Media_httpimgskitchco_lncyt

Read the rest of this post »

YUI DataTable With Rails

[Cross-posted on devchix] I am currently working on an Rails app that integrates the YUI dataTable, and in going through the tutorials I noticed they are all assume a PHP back-end. I also saw a number of people asking how to get this to work with a Rails controller, so I thought I'd write up my experience in the hopes that it helps someone else. For basic info about setting up the dataTable, refer to the YUI site, linked above. I'm also going to try to clarify a few things that I found a bit obscure.

Read the rest of this post »