Closed freegyes closed 8 years ago
https://atmospherejs.com/okgrow/analytics
{
"public": {
"analyticsSettings": {
"Google Analytics" : {"trackingId": "UA-25154644-XXX"},
"Intercom" : {"appId": "fswn6aq0"},
"Mixpanel" : {"token": "a20620cc0e49417b435caf68b7398ad8", "people": true},
}
}
}
XXX is coming soon.
if the okgrow analytics wrapper fails to load intercom.io
need to include this before the closing </body>
tag:
<script>
window.intercomSettings = {
app_id: "fswn6aq0"
};
</script>
<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/fswn6aq0';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
include where the users auth
<script>
window.intercomSettings = {
app_id: "fswn6aq0",
name: "Nikola Tesla", // Full name
email: "nikola@example.com", // Email address
created_at: 1312182000 // Signup date as a Unix timestamp
};
</script>
<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/fswn6aq0';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
window.intercomSettings = {
...
"avatar_set": true,
"friend_count": 32,
"app_id": "fswn6aq0"
}
if the okgrow analytics wrapper fails to load mixpanel
include this snippet before the closing </head>
tag
<!-- start Mixpanel --><script type="text/javascript">(function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" ");
for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f)}})(document,window.mixpanel||[]);
mixpanel.init("a20620cc0e49417b435caf68b7398ad8");</script><!-- end Mixpanel -->
mixpanel.track("Video play");
I added the "okgrow:analytics" Atmosphere pacakge, and configured modulus to use the settings you wrote. "Meteor.settings.public.analyticsSettings" can be accessed by the client (tested).
Please take a look at the trackers.
intercom configured
mixpanel configured (would be nice if added more specific events)
first approach
try to integrate with a global wrapper if all seems well, stop right there
second approach
if global wrapper fails, integrate these manually