JavaScript SDK

Overview

The northDASH JS SDK is opensource code which was originally forked from Mixpanel JS SDK.

Use this SDK to track events from your web application.

Make sure that you have a northDash token before you continue. If you want events from this integration to reach a different table in your DWH, you can request an additional token.



Initialization

Put the following JS code in the header part of your HTML.

Make sure to replace “YOUR_TOKEN” with your actual token.

<!-- northDASH -->
<script type="text/javascript">
(function(e,b){if(!b.__SV){var a,f,i,g;
window.northdash=b;
b._i=[];
b.init=function(a,e,d){function f(b,h){var a=h.split(".");
2==a.length&&(b=b[a[0]],h=a[1]);
b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;
"undefined"!==typeof d?c=b[d]=[]:d="northdash";
c.people=c.people||[];
c.toString=function(b){var a="northdash";
"northdash"!==d&&(a+="."+d);
b||(a+=" (stub)");
return a};
c.people.toString=function(){return c.toString(1)+".people (stub)"};
i="disable time_event track track_custom_event track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" ");
 for(g=0;
     g<i.length;
     g++)f(c,i[g]);
b._i.push([a,e,d])};
b.__SV=1.2;
a=e.createElement("script");
a.type="text/javascript";
a.async=!0;
a.src="undefined"!==typeof NORTHDASH_CUSTOM_LIB_URL?NORTHDASH_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.iknowlogy.net/libs/northdash.min.js".match(/^\/\//)?"https://cdn.iknowlogy.net/libs/northdash.min.js":"//cdn.iknowlogy.net/libs/northdash.min.js";
f=e.getElementsByTagName("script")[0];
f.parentNode.insertBefore(a,f)}})(document,window.northdash||[]);
northdash.init("YOUR_TOKEN", {"api_host":"https://www.iknowlogy.net/jssdk"});
</script>
<!-- northDASH -->


Track an Event

Track any event in your code by using this method:

northdash.track(
  "event_name", {Attributes JSON}
);

For example, placing the following JS code will track an event with event name “pageview” and user_id attribute with value “12345678”:

// Send a "pageview" event
northdash.track(
  "pageview", {
    "user_id": 12345678
  }
);


Included Attributes

Here’s a list of the attributes that are sent by default with any JS event.

  • $os – Operating system
  • $browser – Browser name
  • $browser_version – Only the version number
  • $current_url – the URL of the page from which the event was sent
  • $screen_height
  • $screen_width
  • distinct_id – a cookie based persistent user ID
  • $initial_referrer – the original referring URL of the user
  • $initial_referring_domain – the original referring URL domain of the user
  • token – The northDASH token that was used
Did you find this helpful?11