Updated gem to include Custom Tracking Variables and Events #9

Merged
merged 16 commits into from Mar 20, 2013

Projects

None yet

4 participants

@smontgomerie
Collaborator

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

@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 💤

@smontgomerie
Collaborator

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

@anicholson
Collaborator

@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

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

@smontgomerie smontgomerie Merge branch 'master' of https://github.com/leehambley/rack-google-an…
…alytics

Conflicts:
	lib/rack/google-analytics.rb
	test/helper.rb

All specs pass
01b4a3a
@smontgomerie smontgomerie merged commit 1191f0e into kangguru:master Mar 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment