Integrating customer.io for Sending Right Messages at the Right Time

29 / Jul / 2016 by Tanu Siwag 0 comments

Email marketing present so many benefit over other traditional forms of marketing. It drives better returns on investment and customer engagement metrics than other marketing techniques because of Reduce Overhead Costs and Reduced Time and Efforts.

The old process for sending an email involves only one step as send an email, and that’s it. We have no idea what happens after that email is sent :

  • Did they receive it?
  • Did it get lost in their inbox?
  • Did they click on mail links?
  • Open mail attachments?

All these points can be taken into account by integrating just one third party service i.e. Customer.io.

Customer.io is a third party service that provides the facility to set trigger points for sending emails based on user events and Segmenting users using criteria.

Also using single trigger we can send a series of messages. And it automatically stop sending mails once the user stop matching trigger creteria. It also provide the flexibilty to trigger emails during a defined time period only. We can track user conversions by connecting every message to an action. And can measure the sucess of our email campain.

For integrating customer.io with web app, we have to follow few simple steps:

1. Register your site on Customer.io and it will provide you a SITE-ID and SECRET-API-KEY along with a script

2. Add the script on every page of your site:

<script type="text/javascript">
 var _cio = _cio || [];
  (function() {
    var a,b,c;
  a=function(f){return function(){_cio.push([f].       concat(Array.prototype.slice.call(arguments,0)))}};
  b=["load","identify","sidentify","track","page"];
  for(c=0;c<b.length;c++){_cio[b1]=a(b1)};
  var t = document.createElement('script'),
      s = document.getElementsByTagName('script')[0];
      t.async = true;
      t.id    = 'cio-tracker';
      t.setAttribute('data-site-id', <SITE-ID>);
      t.src = 'https://assets.customer.io/assets/track.js';
      s.parentNode.insertBefore(t, s);
  })();
</script>

3. For the logged in user add following script on your page:

<script type="text/javascript">
_cio.identify({
 id: <UNIQUE-USER_ID>,				//Must be unique per user
 email: <USER-EMAIL-ID>,			//Email-Id of logged in user
 created_at: <User_register_Timestamp>,//User Signup time
 name: <USER-NAME>					//Optional field
});
</script>

We can add as many attributes as we like.

4. In addition to user information, you may want to track user events like “purchased” or “subscribedToNotification”.

<script type="text/javascript">
_cio.track(<EVENT-NAME>);
_cio.track(<EVENT-NAME>, { <ATRIBUTE1>: <ATRIBUTE-VALUE>, <ATRIBUTE2>: <ATRIBUTE-VALUE>, <ATRIBUTE3>: <ATRIBUTE-VALUE>});
</script>

Customer.io also Provides APIs for creating user and add events to it.

 curl -i https://track.customer.io/api/v1/customers/<UNIQUE-USER_ID> \
   -X PUT \
   -u <YOUR-SITE-ID-HERE>:<YOUR-SECRET-API-KEY-HERE> \
   -d email=<USER-EMAIL-ID> \
   -d name=<USER-NAME> \
   -d <ATRIBUTE-NAME>=<ATRIBUTE-VALUE>
curl -i https://track.customer.io/api/v1/customers/<UNIQUE-USER_ID>/events \
   -X POST \
   -u <YOUR-SITE-ID-HERE>:<YOUR-SECRET-API-KEY-HERE> \
   -H 'Content-Type:application/json' \
   -d '{"name":<EVENT-NAME>,"data":{<ATRIBUTE1>: <ATRIBUTE-VALUE>, <ATRIBUTE2>: <ATRIBUTE-VALUE>, <ATRIBUTE3>: <ATRIBUTE-VALUE>}}'

Hope this help you to send right message at right time. :)

FOUND THIS USEFUL? SHARE IT

Leave a comment -