Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.

Commit

Permalink
Update mixpanel implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Carriço committed Mar 26, 2014
1 parent 8c3b309 commit 779cf9c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/analytical/modules/mixpanel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ def init_javascript(location)
<script type="text/javascript">
(function(c,a){window.mixpanel=a;var b,d,h,e;b=c.createElement("script");
b.type="text/javascript";b.async=!0;b.src=("https:"===c.location.protocol?"https:":"http:")+
'//cdn.mxpnl.com/libs/mixpanel-2.1.min.js';d=c.getElementsByTagName("script")[0];
'//cdn.mxpnl.com/libs/mixpanel-2.2.min.js';d=c.getElementsByTagName("script")[0];
d.parentNode.insertBefore(b,d);a._i=[];a.init=function(b,c,f){function d(a,b){
var c=b.split(".");2==c.length&&(a=a[c[0]],b=c[1]);a[b]=function(){a.push([b].concat(
Array.prototype.slice.call(arguments,0)))}}var g=a;"undefined"!==typeof f?g=a[f]=[]:
f="mixpanel";g.people=g.people||[];h=['disable','track','track_pageview','track_links',
'track_forms','register','register_once','unregister','identify','name_tag',
'set_config','people.identify','people.set','people.increment'];for(e=0;e<h.length;e++)d(g,h[e]);
a._i.push([b,c,f])};a.__SV=1.1;})(document,window.mixpanel||[]);
'track_forms','register','register_once','unregister','identify','alias','name_tag','set_config',
'people.set','people.set_once','people.increment','people.track_charge','people.append'];
for(e=0;e<h.length;e++)d(g,h[e]);a._i.push([b,c,f])};a.__SV=1.2;})(document,window.mixpanel||[]);
mixpanel.init('#{options[:key]}');
</script>
HTML
Expand All @@ -32,10 +32,13 @@ def init_javascript(location)

def identify(*args) # id, options
<<-JS.gsub(/^ {10}/, '')
mixpanel.identify(id);
if (options && options.name) {
mixpanel.name_tag(options.name);
if (options) {
mixpanel.people.set(options);
if (options.name) {
mixpanel.name_tag(options.name);
}
}
mixpanel.identify(id);
JS
end

Expand Down

0 comments on commit 779cf9c

Please sign in to comment.