Connecto Web Event Tracking and Notifications


Connecto allows you to personalize your website with notifications based on user’s prior actions. Which means you can actually target the right segments with the right market. For e.g:

  • You can show some discount to a returning user who has not bought before ✔
  • You can get feedback on the last purchase from a returning user ✔
  • If a user has tried to take an action multiple times, you can ask him if he needs help ✔

This and a lot more can be done via Connecto. The path to personalization passes through tracking user actions (events) and understanding their behavior. So let’s get started on that. But first, you will need to include our JS snippet to all the pages of your website where you want to track user actions or events.

Integrating Connecto Script

The following is the snippet for tracking events (Please include the minified version below):

<!–Start of Connecto Tracking script–>
<script type=”text/javascript”>
! function() {
var _connecto = window._connecto = window._connecto || [];
_connecto.methods = [“track”, ”page”, “identify”];
_connecto.factory = function(t) {
return function() {
var e = Array.prototype.slice.call(arguments);
return _connecto
for (var t = 0; t < _connecto.methods.length; t++) {
var e = _connecto.methods[t];
_connecto[e] = _connecto.factory(e);
_connecto.load = function(t) {
window._connecto.writeKey = t;
var con = document.createElement(‘script’);
con.type = ’text/javascript‘;
con.src = document.location.protocol + ‘//api.connecto.io/javascripts/connecto.prod.min.js‘;
var s = document.getElementsByTagName(‘script’)[0];
s.parentNode.insertBefore(con, s);
_connecto.load(‘*** YOUR_LICENSE_KEY ***‘);
<!–End of Connecto Tracking script–>

Minified Version

<!--Start of Connecto Tracking script-->
<script type="text/javascript">
!function(){var a=window._connecto=window._connecto||[];a.methods=["track","identify","page"];a.factory=function(e){return function(){var b=Array.prototype.slice.call(arguments);return b.unshift(e),a.push(b),a}};for(var c=0;c<a.methods.length;c++){var d=a.methods[c];a[d]=a.factory(d)}a.load=function(a){window._connecto.writeKey=a;a=document.createElement("script");a.type="text/javascript";a.async=!0;a.src=document.location.protocol+"//api.connecto.io/javascripts/connecto.prod.min.js";
<!--End of Connecto Script--> 


Please replace ***YOUR_LICENSE_KEY*** in the above snippet with your license key.
You can find your license key at https://app.connecto.io/n/push_notifications#/settings

Tracking Page Views

Now that the script is out of the way, let’s move to the fun part. Suppose you are an eCommerce website and want to understand how many of your users visited a particular page/product now we will simply track that particular page view by calling page function

Track ‘visited adidas shoes page’ action:

‘category': ‘shoes’,
‘product’: ‘adidas’,
‘value’: 2000,

Here, the parameter is JSON object of optional parameters that you may want to send for the page view event.

Tracking Events

Suppose you are an eCommerce website and want to understand how many of your users add product to their cart but never order anything. So, we will track the “Add to Cart” event.

Track ‘Add to Cart’ action:

_connecto.track(‘Add to Cart’, {
‘category': ‘Mobile’,
‘product’: ‘Moto X Mobile’,
‘value’: 19999,

Here, the first parameter is the event name and the second parameter is JSON object of optional parameters that you may want to send for an event.

Similarly you can track an order event.

Track ‘Order’ action

_connecto.track(‘Order’, { ‘value’: 19999 })

Note: Connecto by default assigns an anonymous ID to every user. This ID is persisted across his sessions on the same browser. However, it’s better to identify a user with a unique ID from your system so that this user can be tracked uniquely across devices and browsers. You can use our identify call to do that.

Identify Call

_connecto.identify(userId, traits) which will look like:
_connecto.identify(‘ABCD1234′, {
‘$name': ‘ABCD’,
‘$email': ‘abcd@connecto.io‘,
‘$phone': +91-8888888888,

Once you have set up this tracking and identification, you can now target a user by the number of ‘Add to Cart’ events, ‘Order’ events, his age, time since a user did those events and many more of such metrics.

Using these events, you will be able to segment and target users by rules of type:

  • User has added something to cart in the last one week / more than 7 days ago.
  • User has added something to cart twice until now.
  • User has placed more than 2 orders.
  • User has added something of category ‘Mobile’ in cart.

To get more details on each of these calls and how to use them on other platforms, please refer the API spec document.

2 found this helpful