Skip to content

Instantly share code, notes, and snippets.

@buger
Created December 18, 2012 10:56
Show Gist options
  • Save buger/4327086 to your computer and use it in GitHub Desktop.
Save buger/4327086 to your computer and use it in GitHub Desktop.
Migration from intercom.io to analytics.js

Migrating from intercom.io to analytics.js

Intercom.io use 2 level hash and separate user identification and user tracking. Analytics.js use plain hash to handle both identification and tracking. Below you can see migration scheme:

var intercomSettings = {                         analytics.initialize({
                                                    
  app_id: 'bk7tlzy4',                              'Intercom': 'bk7tlzy4'
                             
                                                 });
  
  user_id: '9876',                               analytics.identify('9876', {
  
  // NOTE: analytics.js use created instead of created_at  
  created_at: 1234567890,                          created: 1234567890, 
  
  name: 'John Doe'                                 name: 'John Doe',
  email: '[email protected]'                    email: '[email protected]'                                                  
                                                    
  custom_data: {                                   // Custom data goes in same hash
    priceplan: "Small",                            priceplan: "Small",
    active_accounts: 12                            active_accounts: 12
    ...                                            ...
  }                                              });  
};

Intercom secure mode

If you want to use intercom using secure mode http://docs.intercom.io/#SecureMode you can initialize analytics.js this way:

analytics.initialize({
  'Intercom': {
    app_id: 'bk7tlzy4',
    user_hash: "<%= Digest::SHA1.hexdigest('u35ijdqw' + current_user.email) %>"
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment