aedm / yearcompass

Web application for year planning and personal development
0 stars 0 forks source link

include tracking code snippet #25

Closed freegyes closed 8 years ago

freegyes commented 9 years ago

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

freegyes commented 9 years ago

https://atmospherejs.com/okgrow/analytics

{
  "public": {
    "analyticsSettings": {
      "Google Analytics"   : {"trackingId": "UA-25154644-XXX"},
      "Intercom"           : {"appId": "fswn6aq0"},
      "Mixpanel"           : {"token":  "a20620cc0e49417b435caf68b7398ad8", "people": true},
    }
  }
}
freegyes commented 9 years ago

XXX is coming soon.

freegyes commented 9 years ago

intercom.io integration

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>
for live user tracking

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>
in case we need individual data
window.intercomSettings = {
...
  "avatar_set": true,
  "friend_count": 32,
  "app_id": "fswn6aq0"
}
freegyes commented 9 years ago

mixpanel integration

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 -->
in case we need to track specific events
mixpanel.track("Video play");
aedm commented 8 years ago

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.

freegyes commented 8 years ago

screen shot 2015-11-30 at 14 56 21 intercom configured

freegyes commented 8 years ago

screen shot 2015-11-30 at 15 01 52 mixpanel configured (would be nice if added more specific events)