kangguru / rack-google-analytics

Simple Rack middleware for implementing google analytics tracking in your Ruby-Rack based project. Supports synchronous and asynchronous insertion and configurable load options
MIT License
257 stars 53 forks source link

Updated gem to include Custom Tracking Variables and Events #9

Closed smontgomerie closed 11 years ago

smontgomerie commented 12 years ago

These commits add fully unit-tested code for adding custom variables and events to google analytics in async mode. Usage is described in the README.

Essentially it allows users to specify custom variables and events in their application controllers. It accomplishes this by adding instance methods to the ActionController::Base class. These methods store data in the environment to pass to rack, and write the variables when rendering the GA javascript tags.

The documentation for Google Analytics tracking requirements is detailed here: https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide

Open to discussion on code style. Particularly, I'm not sure I like this syntax:

    set_ga_custom_var(1, "LoggedIn", value, GoogleAnalytics::CustomVar::SESSION_LEVEL)

I might prefer to modify the method to take a hash:

    set_ga_custom_var( :slot => 1, :name => "LoggedIn", :value => value, :scope => GoogleAnalytics::CustomVar::SESSION_LEVEL)
leehambley commented 12 years ago

@smontgomerie added you as a contributor, you should be able to push upstream now.

In the meantime that should do - I will add you to rubygems.org too as soon as figure out how (if you have prior experience please let me know) I'm going on vacation in about 14 hours, and I need to sleep between now and then, so i'm a little tight on time :zzz:

smontgomerie commented 12 years ago

Great, thanks! If you have any comments on the code I'd love your feedback. Have a great vacation!

anicholson commented 11 years ago

@smontgomerie @leehambley hi guys, looking to use this middleware in a project, but I'd need this PR for event tracking. Is that going to be merged any time soon?

Cheers :)

leehambley commented 11 years ago

This pull request cannot be automatically merged.

I've given you commit access, when you've resolved the changes, I'll be happy to push a release to rubygems.org