SDK Overview

JavaScript SDK is loaded through our snippet, and is available on the global context (window) under the name you assign on code snippet:

<script type="text/javascript">
  if (typeof $igniter_var === 'undefined') {
    !function n(t,c,r,o,a,i,s,e,f,l,u){l=null!=t[r]&&"function"==typeof t[r].now?t[r].now():null,t.$igniter_var=i,t[i]=t[i]||function(){(t[i].q=t[i].q||[]).push(arguments)},e=c.getElementsByTagName(o)[0],(f=c.createElement(o)).async=1,"//cdn"==a?(t[i].s=l,f.onerror=function(e){t[i].e=e,n(t,c,r,o,a+"-fallback",i,s)}):t[i].r=l,(u=!t.Promise||!t.MutationObserver||!Object.assign)||(t[i].v="nbc"+(0<=a.indexOf("-fallback")?"f":"")),f.src=a+".petametrics.com/"+s+(u?"":"-nbc")+".js?ts="+(+new Date/36e5|0),e.parentNode.insertBefore(f,e)}(window,document,"performance","script","//cdn","$p","{JAVASCRIPT_KEY}");

    $p('init', "{JAVASCRIPT_KEY}");
    $p('send', "pageview");
  }
</script>

As you see in the end of the first line:

(window,document,"performance","script","//cdn","$p","{JAVASCRIPT_KEY}")

The last argument defines the namespace in which our SDK is accessible through. We set it to $p by default but you may change it to $li or any other form you're comfortable with in case $p is already taken for you.

$p functions can be invoked by passing in the string that specifies a function. This is followed by an argument that's specific to the function, and then an options object where you have the option of defining a callback or certain configurations.

For example, line 9 shows our init function, with the Javascript Key passed in as the second argument. But you can also pass in an optional options object as the third argument that configures our script.

Single Page Application Integration

On a standard web flow there is a predictable site navigation procedure (request a new page, loads the page, and etc). However, Single Page Applications are usually like standard Apps in that you load it once and have its state changed in response to user's actions.

Most of Single Page Application Integration is just disabling automated activities that our JavaScript SDK assumes from a standard web flow such as pageview and cookie update, and manually handling those according to how you define user flow on your app.