A blog from Brandon Moser, a Senior Web Developer. Mostly code, sometimes I post about drumming, UX and/or loyalty.

Tracking Page Views in CFWheels w/Google Analytics

Today I was tasked with tracking page views and email campaigns in Google Analytics (GA) within our CFWheels application. I found a great option in GA to track events. Thinking about how the framework is designed, we essentially are using Events (like most frameworks) to control the application. Within Event Tracking in GA, you define a Category (controller) for the Event. Then,  define the Action (action). The _trackEvent() method also accepts 2 other parameters, opt_label, which is an option descriptor for the event and opt_value, which is a number (positive integer).

To add this to your GA script snippet, just add the following line:

_gaq.push(['_trackEvent', '<cfoutput>#params.controller#</cfoutput>', '<cfoutput>#params.action#</cfoutput>']);

Once you have added this snippet to your GA script you will find the report under Content >> Event Tracking. From here you will be able to determine the usage of your app without having to create Custom Reports.

Speaking at cf.Objective() 2011

So, it a bit of unexpected news, I received an invitation to speak the cf.Objective() conference in May 2011. The topic is titled, "SQL Performance for the Common Man." It will cover basics of set operations vs. functional programming, intros to how to run a SQL Explanation in MSSQL, MySQL & Oracle, understanding Transaction Isolations and some basic design tips. There is another session on Database Tuning, so my topic will be more of an intro to SQL Performance versus getting down in the trenches and really making huge changes in your SQL.

First Github project: CF.Objective Badger

 With a little reminder/push from @markdrew and @cfjedimaster, I created and submitted my first project to and When I created the plugin, I thought about what I was going to do for versioning, but didn't think about hosting it on It should have been an obvious choice. Getting the project setup was really easy. I just followed the walk-through from and immediately saw my project come to life as an OSS project.

Here are the steps I took:

  • Register for (I did this months ago to watch and fork other projects)
  • Install GIT
  • From the Dashboard, click New Repository
  • Enter the Project Name, Description and Homepage URL (link back to my projects)
  • If you don't have an SSH key for your email login, you will need to create that key, here are the commands:

ssh-keygen -t rsa -C "[email protected]"
cat ~/.ssh/ | pbcopy(this will copy your new key to the clipboard)
  • Add your key to the SSH Public Keys in the Account Settings
  • Open Terminal (Mac OSX), run the following commands:
    (You might want to create the README and LICENSE files prior to committing the project)

cd [project directory]
git init
  • Make sure you have a README file, with contents

touch README
  • Make sure you have a LICENSE file if you are going to submit to, but a good idea either way

  • This adds all files that are uncommitted

git add *
git commit -m 'first commit'
git remote add origin [email protected]:[username]/[projectname].git
git push -u origin master
  • Click continue on the screen with the instructions, if your project was pushed correctly, you should see the homepage for your project with a listing of the files.

Next I went to and submitted my project for inclusion, since it is ColdFusion related.

I need to add to my project the language, so that it is included in the ColdFusion projects, but I haven't figured out how to do that, yet.

First Mango Plugin Created

 I created my first plugin for Mango Blog. Wow, that was super easy. The plugin is really simple, just adds a cf.Objective 2011 badge to the sidebar. I used another plugin, SOTR2010, from Guust Nieuwenhuis as a template. I'm not sure the documentation on the Mango Blog site would have been enough, but the fact that plugins are open source, it really makes it easy to learn from others.

Here is the link to the plugin and my new projects page, now required as I have a project to maintain.

Continuation of the CFML Open Source Projects Update

Last week Brian Rinaldi wrote a post that said that he would no longer be updating the OSS Updates for CFML. Many in the community thanked him for his work (myself included). A few of us decided that it should continue on and with that have started a group that will look at all (ok, as much as we can find) Open Source Software projects in the CFML community. Our hope is to feature the current projects, notify people on ongoing and updated projects and help push for more projects to be open sourced.

There are many places to find these projects, from and Our hope is to bring these sources together and allow the community to keep up-to-date on these projects, as Brian did.

Currently, we have a project plan in place and hope to secure a domain name and host shortly.


Local Web Dev Platform

In an effort to remember how I setup my systems on both my Mac and my PC at work, I have decided to post my setup here. Hopefully it helps others, not just myself.

Since I like to control my web server separate from my application server (PHP, ColdFusion, Railo, Java, etc.), I use Apache HTTP, as it allows me to setup multiple virtual hosts (websites) vs. IIS on Windows XP or 7. I don't do much PHP development these days, but the other nice thing to using Apache is that most installs include PHP4/5 already. I have found that XAMPP for Mac and Wamp Server on Windows are the easiest to work with and allow you to customize the web server as needed. I tried MAMP for Mac and because I didn't want to pay for the ability to create vhosts (virtual hosts), I switched to XAMPP and have found no issues in its setup.

Setting up my CFML engine was easy, since Adobe ColdFusion has a built-in script for attaching itself to Apache's http.conf configuration file. I also run Railo on my VPS, but because I also run Tomcat on the VPS, configuration there was a bit more complicated (an honestly, I'm still working out the kinks). If you install the Apache server first, installing the ColdFusion connector script is a breeze. When it asks for the server to use, point it to the http.conf directory location and it will add the following code to your config file.

# JRun Settings LoadModule jrun_module /Applications/ColdFusion8/runtime/lib/wsconfig/1/ JRunConfig Verbose false JRunConfig Apialloc false JRunConfig Ignoresuffixmap false JRunConfig Serverstore /Applications/ColdFusion8/runtime/lib/wsconfig/1/ JRunConfig Bootstrap #JRunConfig Errorurl url #JRunConfig ProxyRetryInterval 600 #JRunConfig ConnectTimeout 15 #JRunConfig RecvTimeout 300 #JRunConfig SendTimeout 15 AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc .cfr .cfswf

Adobe's ColdFusion also has an option to install the above script on an existing Apache install if you have both ColdFusion installed and Apache HTTP and you didn't connect them during install. You can find option in the Mac ColdFusion Launcher application, under Serivce menu >> Webserver Connection Utility.

Also important to a local development setup is using local web addresses to mimic the production/staging setup. For example, I have setup in my home workspace to mimic this blog. Obviously, the .dev domain does not exist, but adding them to my hosts file, makes using these domains very easy. It also allows me to quick know which site I am developing. To find your hosts file on Windows it is found in "%system_root%\system32\drivers\etc\hosts". On Mac it is hidden a little more and requires Admin/root access so tools like TextWrangler or TextMate make things much easier. The hosts file location on Mac OS X is located in "/etc/hosts". While that doesn't seem very hidden Mac OSX keeps directories like /etc, /var & /opt hidden from user view, especially in the Finder. I usually add both the www and root domains to my hosts file, (e.g. &, just in case I decide to manually type in the URL.

Add virtual hosts to Apache is a breeze once you have a good template. I like to keep them in a separate file for cleanliness and ease of find them. There is a line in most Apache http.conf that allow for this. If not you can add it anywhere.

# Virtual hosts Include etc/extra/httpd-vhosts.conf

Running virtual hosts, also allows to you keep your development directories organized and located as you please. I like to keep my work projects separate from my personal projects. I keep all of them in my user's Sites directory, but within that directory is a director for Denali (my current employer) and Personal. Below is a sample vhost code sample.

DocumentRoot "/Users/brandonmoser/Sites/mango/" ServerName ServerAlias ErrorLog "logs/" CustomLog "logs/" common

Keeping separate error and access logs allows me to quickly parse the log, when something goes wrong. Obviously in development you don't have multiple sites being accessed at once, so you can comment out the log config to use the default logs which are setup in the http.conf file.