Track API

Track v1 Overview

Web SDK vs Backend Integrations

  <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[b[c]]=a(b[c])};
          var t = document.createElement('script'),
              s = document.getElementsByTagName('script')[0];
          t.async = true;
          t.id    = 'cio-tracker';
          t.setAttribute('data-site-id', 'YOUR_SITE_ID');
          t.setAttribute('data-use-array-params', 'true');
          t.src = 'https://assets.customer.io/assets/track.js';
          s.parentNode.insertBefore(t, s);
      })();
  </script>

You can integrate with this API using a javascript snippet, by consuming the API directly, or both.

You can simply copy/paste the Javascript snippet to your site to track basic customer behaviors directly from your website. In many cases, using the Javascript snippet is easier to integrate with your app, but there are several reasons why you may want to send events from your backend systems:

  • Ad blockers are becoming more prevalent as people and browsers increasingly try to avoid 3rd-party JS trackers.
  • You don't plan to trigger emails based on how customers interact with your website (e.g. users who haven’t visited the site in X days).
  • You use the Javascript snippet, but have a few events you’d like to send from your backend system. They will work well together!
  • You would rather not have another Javascript snippet slowing down your frontend. Our snippet is asynchronous (doesn’t affect initial page load) and very small, but we understand.

You should base your decision to send events from your backend or a Javascript snippet on what works best for you. You can fully integrate with Customer.io using either approach.