Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.
/ segment-rails Public archive

A rails plugin for logging data with Segment on the client side.

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt
Notifications You must be signed in to change notification settings

cohere-coop/segment-rails

Segment-Rails

Segment is an incredible layer of abstraction between your application and analytics systems. It's major benefit is when tracking events at the user interface side. This includes all kinds of great meta data about the user that isn't available on the server.

In client rendered apps this isn't a problem. Do event tracking at the JavaScript layer once the event is verified as successful! In server-side apps, the browser doesn't have a clear way of knowing whether an action was successful or not.

To get that oh-so-sweet client side meta-data while still maintaining the rapid development and accessibility of server-side rendering; we enqueue user action events in a cookie. We use JavaScript to read the queue and track the events with Segment. Mmmm, now we get the lovely referring domain and utm data!

Installation + Usage

  1. Add segment-rails to your Gemfile
  2. Configure segment-rails in your ApplicationController
class ApplicationController < ActionController::Base
  include SegmentRails

  def user_identifier
    current_user ? current_user.id : nil
  end
end
  1. Instrument your controllers with track_event("Timmy fell down the well", { reporter: :lassie })
  2. Profit! (Or at least, observe behaviors which you hope will lead to profit)

About

A rails plugin for logging data with Segment on the client side.

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt

Code of conduct

Stars

Watchers

Forks

Packages

No packages published