To use Javascript API you need include main Javascript snippet code before the closing </body> tag of all your pages:

<script type="text/javascript">
    window.omnisend = window.omnisend || [];
    omnisend.push(["accountID", "<YOUR_BRAND_ID>"]);
    omnisend.push(["track", "$pageViewed"]);
    !function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src="";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}();

Replace <YOUR_BRAND_ID> with your brandID, which you can find in panel, Integrations & API part.

$pageViewed event is used for Live View Website Tracking. If you don't want us to track page views - you can remove omnisend.push(["track", "$pageViewed"]); from snippet.

If you already have connected your store or application with Omnisend - you have already added this snippet.

onSuccess and onError functions

You can define your own onSuccess and onError functions. They will be called after request.
Use callbacks event property:

omnisend.push(["track", "<eventName>",{
    propertyName: "propertyValue",
    callbacks: {
        onSuccess: function() {
         onError: function() {