chexton
2/27/2013 - 2:09 AM

segmentio-getting-started.js

segmentio-getting-started.js

// Each of these should be surrounded by <script> tags.

//1. Install library from Segment.io. Grab this via 'Setup Guide'. It's user-specific so I won't copy here.
  
//2. This goes in the head to identify logged in customers:

analytics.identify('replace-with-customer-id', { // You can use email for the ID if you want
    name             : 'Achilles',
    email            : 'achilles@segment.io',
    subscriptionPlan : 'Premium',
    friendCount      : 29
});

//3. Track when customers view a product:

analytics.track('Purchased an Item', {
    name    : 'Test product',
    url     : 'http://linktoproduct.com'
});

//4. Track when they view their cart:

analytics.track('Views cart');

//5. Track when they begin checkout:

analytics.track('Begin checkout';

//6. Track when they complete checkout:

analytics.track('Completed checkout');