Webtrends::Rails
Make use of Webtrends gem to allow server-side tracking in a Rails application.
Installation
Add this line to your application's Gemfile:
gem 'webtrends-rails'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install webtrends-rails
Usage
Controller configuration
Track hook
track :object_to_track, options, optional_block
NOTE: Any options that can be passed to before_action can be used as options.
By default the track hook will use the following tags:
- dcsuri: request path (ex. /path/to/service)
- dcsdat: milliseconds since epoch
- dcssip: hostname
- WT.es: hostname + dcsuri
- WT.co_f: webtrends visitor id
NOTE: dcsuri is the only mandatory tag for event tracking. If dcsuri is not passed you will get a 400 Bad Request response
Tracking with custom tags
track :object_to_track, only: :create do |tags|
tags.store('your_custom_tag', 'custom_tag_value')
end
Tracking with default tags
track :object_to_track, only: [:create, :update]
Model configuration
ActiveRecord
Make use of an after_save hook to call track_event
after_save :track_event
ActiveModel
Make use of an after_validation hook to call track_event
after_validation :track_event, if: 'errors.blank?'
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Create tests for your feature
- Make sure coverage meets minimum requirements
- Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request