track anonomous user segments via analytics (let's see how successful the beta channel features are)
This commit is contained in:
parent
90919fa488
commit
c06e8b3329
4 changed files with 13 additions and 0 deletions
|
|
@ -40,6 +40,12 @@ module ApplicationHelper
|
|||
javascript_tag("Modernizr.mq('(min-width:0)') || document.write(unescape('#{j javascript_include_tag("mbp-respond.min")}'));")
|
||||
end
|
||||
|
||||
# This will *only* fire if analytics are configured (don't panic!)
|
||||
def include_advanced_segments
|
||||
segment = current_user ? current_user.role_name : "unauthenticated"
|
||||
javascript_tag("if(window._gaq) { _gaq.push([1, 'Role', '#{segment}']) }")
|
||||
end
|
||||
|
||||
# Require jQuery from CDN if possible, falling back to vendored copy, and require
|
||||
# vendored jquery_ujs
|
||||
def jquery_include_tag
|
||||
|
|
|
|||
|
|
@ -433,6 +433,10 @@ class User < ActiveRecord::Base
|
|||
Role.is_admin?(self.person)
|
||||
end
|
||||
|
||||
def role_name
|
||||
role = Role.find_by_person_id(self.person.id)
|
||||
role ? role.name : "user"
|
||||
end
|
||||
|
||||
def guard_unconfirmed_email
|
||||
self.unconfirmed_email = nil if unconfirmed_email.blank? || unconfirmed_email == email
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
= set_current_user_in_javascript
|
||||
= translation_missing_warnings
|
||||
= current_user_atom_tag
|
||||
= include_advanced_segments
|
||||
|
||||
= yield(:head)
|
||||
= csrf_meta_tag
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@
|
|||
= set_asset_host
|
||||
= translation_missing_warnings
|
||||
= current_user_atom_tag
|
||||
= include_advanced_segments
|
||||
|
||||
- if @post.present?
|
||||
%link{:rel => 'alternate', :type => "application/json+oembed", :href => "#{oembed_url(:url => post_url(@post))}"}
|
||||
= og_page_specific_tags(@post)
|
||||
|
|
|
|||
Loading…
Reference in a new issue