Read my latest article: 8 things I look for in a Ruby on Rails app (posted Thu, 06 Jul 2017 17:59:00 GMT)

Lessons in Open Source

Posted by Mon, 27 Jun 2016 17:04:00 GMT

A few months ago, I wrote an article on Medium about my experience of starting Oh My Zsh. Thought I’d share it for the few lingering readers over here, too.

d’Oh My Zsh: How I unexpectedly built a monster of an open source project

GitHub prepares to release Atom

Posted by Wed, 26 Feb 2014 04:35:00 GMT

...which leads us to

Initial sources suggest that will be one of the biggest app releases of the year.

It’ll be loved by many. Hated by some.

For more details… visit Atom.io or Atom Beta

Dear @ohmyzsh users… we are ready! ;-)

Updates

As we learn more… I will try to keep this updated. Here are a few “screenshots” people have posted on twitter.

Some animated gifs:

</>

Stay tuned…

You might consider following @AtomEditor on twitter.

oh-my-zsh reaches over 500 contributors

Posted by Sun, 01 Dec 2013 21:29:00 GMT

Earlier today, I noticed that we now have over 500 developers from around the globe who I have accepted pull-requests from1. That is so fantastic.

Thanks to each and every one of you who has helped make this project so wonderful for others. :-)

1 This number could be a lot higher if I spent more than a hour or two a week on this, but I’m a big fan of slow and steady… a good number of the open pull-requests are themes at the moment.

Tracking Google Analytics events in development environment with GoogleAnalyticsProxy

Posted by Sun, 01 Nov 2009 19:55:00 GMT

1 comment Latest by Justin Gallagher Sun, 03 Jan 2010 23:11:32 GMT

As mentioned in a recent article1, I’ve been diving deep into Google Analytics lately while working on a few client projects. We’re aiming to use much more of the features of Google Analytics and have been hitting some roadblocks with the development versus production application environments. Once you begin to dive into event tracking and AJAX-driven goal conversions, relying on just the sample code that Google Analytics provides you is going to result in you looking at a handful of JavaScript errors.

pageTracker is not defined

another example from the firebug javascript console…

firebug pageTracker is not defined

We see JavaScript errors like this because we don’t load the google analytics code in our development environments. As you can see, we are only loading this in our production environment.

  <% if RAILS_ENV == 'production' -%>
    <!--// Google Analytics //-->
    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    var pageTracker = _gat._getTracker("UA-XXXXXX-1");
    pageTracker._trackPageview();
    </script>
  <% end -%>

To track an event with Google Analytics, you’d need to trigger something like:

  pageTracker._trackEvent('Button', 'Click', 'Get in touch');

As you can see from our code earlier, in development, the pageTracker variable isn’t defined and that’s why we’re getting those JS errors. We also don’t want to add conditionals everywhere in our application to check if we’re in development or production environment.. as that’d just make our views uglier than they need to be. So, I decided that I’d create a proxy class in JavaScript that would allow us to trigger _trackEvent() and _trackPageview() and handle it appropriately.

This class works with the following logic:

  • if google analytics is loaded, pass the parameters to the real pageTracker
  • if google analytics is NOT loaded, output the information to console.log() for debugging purposes

For example, on a gallery on our web site… we track when people navigate next and/or previous through the photos. In our development environment, I can watch the JavaScript console output the following:

Firebug - GAP

And in our production environment, we can see that this was sent to Google Analytics.

Firebug - trackEvent()

We’re able to do this by initializing the GoogleAnalyticsProxy class and calling these functions through it. For example:

  _gap = new GoogleAnalyticsProxy();
  _gap._trackEvent('Video', 'Play', 'Homepage video');
  _gap._trackEvent('Video', 'Pause', 'Homepage video');
  _gap._trackEvent('Button', 'Click', 'Call to action X');

You’ll see that we’re just calling _gap versus pageTracker. We then replace all the instances of pageTracker (except where it is defined in the google analytics code block they provide you). You’ll find this located near the bottom of our application.html.erb file.

<% if RAILS_ENV == 'production' -%>
  <!--// Google Analytics //-->
  <script type="text/javascript">
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  </script>
  <script type="text/javascript">
  var pageTracker = _gat._getTracker("UA-XXXXXX-1");
  pageTracker._trackPageview();
  </script>
<% end -%>

<script type="text/javascript">
  var _gap = new GoogleAnalyticsProxy();
</script>

We now have _gap available throughout our project and can call _trackEvent() and _trackPageview() with it. Note: You can use any JS variable name that you want, _gap is just what I went with.

Get GoogleAnalyticsProxy

I’ve gone ahead and tossed this small JavaScript class (known as GoogleAnalyticsProxy) on Github for your enjoyment. I have some more articles in the works that will show you some tips for how to make the most of Google Analytics. If you have any questions and/or ideas for related article topics, don’t hesitate to let me know.

1 Tracking AJAX-driven events in Ruby on Rails for Google Analytics conversion goals

Portland a hub for Open Source?

Posted by Fri, 02 Dec 2005 02:28:00 GMT

I saw the following article posted on O’Reilly Radar.

Oregon city builds a reputation as a hub for software revolution

We have tons of Open Source stuff in this town… from OSCONOSL to OSDL (where Linus himself works)... to tons of local user groups. Starting a business in Portland, Oregon that focuses on Open Source technology is so common place that it’d be nuts to even attempt to list all the companies that I am aware of.

PLANET ARGON was started in Portland, Oregon and as we are slowly moving our way into other regions of the country with some of our extended developers, we are so excited to be part of the Portland scene.

We’re looking forward to meeting so many of you next summer at OSCON 2006!

If you’re a reader of this blog and in the Portland area… leave me a comment!

I wonder how many readers are located in the Portland area. :-)

I <3 Portland.