Segment Integration Stepwise Guide


#1

How to do Segment Integration with CleverTap?


#2

Here is the Stepwise Guide on how to Integrate CleverTap with Segment.com for Analytics:

When we integrate our website with Segment and CleverTap the flow looks something like:
MyWebsite->Segment->CleverTap

Following are the Integration steps:

  • Go to https://segment.com/
  • Sign Up with your credentials
  • Add Source (MyWebsite) and Destination (CleverTap)
  • To enable Source, add the below script to your website
<script>
  !function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t){var e=document.createElement("script");e.type="text/javascript";e.async=!0;e.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};analytics.SNIPPET_VERSION="4.0.0";
  analytics.load(“YOUR KEY”);
  analytics.page();
  }}();
</script>
  • Paste the key that is present in the Source->Settings->API Key->Write key in place of “YOUR KEY” in the above script.
  1. To enable Destination, add the CleverTap Account ID and Token
  2. Now you will have a URL generated: https://segment.com/clevertap-nikita/sources/mywebsite/overview
  3. In the Source page we have Debugger and Schema
    Debugger will track the events/profiles pushed and Schema will tell you the code snippet used for the same.
  4. To start a test, you can push the following code to push the profiles and the events respectively:
analytics.identify('f4ca124298', {
  name: 'Michael Bolton',
  email: 'mbolton@initech.com'
});

analytics.track('Signed Up', {
  plan: 'Enterprise'
});

  • Now, both profile and event pushed are visible on Segment as Segments-> Source->Debugger and in the CleverTap Dashboard under Find people and Events