To use Javascript API you need include main Javascript snippet code before the closing </body> tag of all your pages:
<script type="text/javascript">
//OMNISEND-SNIPPET-SOURCE-CODE-V1
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="https://omnisnippet1.com/inshop/launcher-v2.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}();
</script>
Replace <YOUR_BRAND_ID>
with your brandID
, which you can find in app.omnisend.com 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() {
console.log("ok");
},
onError: function() {
console.log("error!");
}
}]);