add guid to mixpanel
This commit is contained in:
parent
de680216f0
commit
ca492b407c
1 changed files with 14 additions and 3 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
module AnalyticsHelper
|
module AnalyticsHelper
|
||||||
def include_mixpanel
|
def include_mixpanel
|
||||||
include_analytics "mixpanel" do |service_uid|
|
include_analytics "mixpanel" do
|
||||||
javascript_tag do
|
javascript_tag do
|
||||||
<<-JS.html_safe
|
<<-JS.html_safe
|
||||||
(function(d,c){var a,b,g,e;a=d.createElement('script');a.type='text/javascript';a.async=!0;a.src=('https:'===d.location.protocol?'https:':'http:')+'//api.mixpanel.com/site_media/js/api/mixpanel.2.js';b=d.getElementsByTagName('script')[0];b.parentNode.insertBefore(a,b);c._i=[];c.init=function(a,d,f){var b=c;'undefined'!==typeof f?b=c[f]=[]:f='mixpanel';g='disable track track_pageview track_links track_forms register register_once unregister identify name_tag set_config'.split(' ');
|
(function(d,c){var a,b,g,e;a=d.createElement('script');a.type='text/javascript';a.async=!0;a.src=('https:'===d.location.protocol?'https:':'http:')+'//api.mixpanel.com/site_media/js/api/mixpanel.2.js';b=d.getElementsByTagName('script')[0];b.parentNode.insertBefore(a,b);c._i=[];c.init=function(a,d,f){var b=c;'undefined'!==typeof f?b=c[f]=[]:f='mixpanel';g='disable track track_pageview track_links track_forms register register_once unregister identify name_tag set_config'.split(' ');
|
||||||
|
|
@ -15,13 +15,24 @@ module AnalyticsHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mixpanel_guid_block
|
||||||
|
return unless current_user
|
||||||
|
include_analytics "mixpanel" do
|
||||||
|
javascript_tag do
|
||||||
|
<<-JS.html_safe
|
||||||
|
mixpanel.name_tag(#{current_user.guid});
|
||||||
|
JS
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def chartbeat_head_block
|
def chartbeat_head_block
|
||||||
return unless configured?("chartbeat")
|
return unless configured?("chartbeat")
|
||||||
javascript_tag("var _sf_startpt=(new Date()).getTime()")
|
javascript_tag("var _sf_startpt=(new Date()).getTime()")
|
||||||
end
|
end
|
||||||
|
|
||||||
def include_chartbeat
|
def include_chartbeat
|
||||||
include_analytics "chartbeat" do |service_uid|
|
include_analytics "chartbeat" do
|
||||||
javascript_tag do
|
javascript_tag do
|
||||||
<<-JS.html_safe
|
<<-JS.html_safe
|
||||||
var _sf_async_config = { uid: "#{AppConfig[:mixpanel_uid]}", domain: "#{AppConfig[:pod_uri].host}" };
|
var _sf_async_config = { uid: "#{AppConfig[:mixpanel_uid]}", domain: "#{AppConfig[:pod_uri].host}" };
|
||||||
|
|
@ -49,7 +60,7 @@ module AnalyticsHelper
|
||||||
|
|
||||||
def include_analytics(service, &block)
|
def include_analytics(service, &block)
|
||||||
return unless configured?(service)
|
return unless configured?(service)
|
||||||
yield block, service_uid=AppConfig["#{service}_uid".to_sym]
|
yield block
|
||||||
end
|
end
|
||||||
|
|
||||||
def configured?(service)
|
def configured?(service)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue