Skip to content

Instantly share code, notes, and snippets.

@bbeaird
Last active August 29, 2015 14:17
Show Gist options
  • Save bbeaird/1297b4eb382d500e7d94 to your computer and use it in GitHub Desktop.
Save bbeaird/1297b4eb382d500e7d94 to your computer and use it in GitHub Desktop.
def anonymousId provider
case provider
when "Segment"
anonId = request.cookies["ajs_anonymous_id"].gsub("\"", "")
when "Mixpanel"
mp = request.cookies.detect{ |key| key.to_s =~ Regexp.new("mp_.+_mixpanel") }[1].split(': ')
anonId = mp[1].gsub(",\"$initial_referrer\"", "").gsub("\"", "")
when "Google"
anonId = request.cookies["_ga"][6..-1]
else
puts "Unrecognized provider"
end
anonId
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment