staccato-rails icon indicating copy to clipboard operation
staccato-rails copied to clipboard

Docs for using session cookie from GA

Open tpitale opened this issue 10 years ago • 3 comments

How to use cookie from GA on the rails backend.

tpitale avatar Sep 06 '15 04:09 tpitale

Currently setting it up in my app. Some info lies here https://github.com/tpitale/staccato/issues/38 .

jtomaszewski avatar Oct 14 '15 22:10 jtomaszewski

I added such method to my ApplicationController:



  def staccato_client_id
    session["staccato.client_id"] ||= cookies["_ga"].split(".").last(2).join(".") if cookies["_ga"]
    session["staccato.client_id"] ||= Staccato.build_client_id
  end

This will parse the client_id which is set automatically by GA JS library (see this comment for more info). I will test it tomorrow.

If it works correctly, should we merge it in the master?

jtomaszewski avatar Oct 14 '15 23:10 jtomaszewski

Based on this comment, I would probably not want this in code, but we could definitely add it to the README.

tpitale avatar Oct 15 '15 14:10 tpitale