Error in javascript tracker


#1

I am getting an error whenever I use the javascript tracker. The error is in line 54, Column 672 on the following call:

E.send(g.stringify(A))

The error message is

sp.js - Uncaught InvalidStateError: Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.q @ sp.js:onreadystatechange @ sp.js

Here is my initialization code:

<!-- Snowplow starts plowing -->
<script type="text/javascript">
(function () {
    ;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
    p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
    };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
    n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d63r508qjur44.cloudfront.net/2.4.1/sp.js","spvb"));
    window.spvb('newTracker', 'co', 'tracking.viewbix.com', { // Initialise a tracker
      appId: 'az-viewbix-player', // Application ID can be anything you want
      platform: 'web', // Do not change
post: true,      // Use POST rather than GET
bufferSize: 1,    // Wait for 5 events to be recorded then send them all into Snowplow via a single POSTS request. You can set this to whatever you want -  if you don't set it it will defuault to 1
cookieName: "_vbtrck_" // Name the viewbix cookie. This will prevent another Snowplow tracker writing to the same cookie, e.g. if a Viewbix ad unit is shown on a publisher site where Snowplow is running
    });
}());
</script>
<!-- Snowplow stops plowing -->

We call the tracker like this:

window['spvb'](
  'trackUnstructEvent', {
      'schema': mySchema
      , 'data': myData}
  , myContexts);

Please help.


#2

From discussing this offline (the poster is a Snowplow customer), it looks like this is a CORS issue from running the Snowplow JavaScript Tracker from a local development machine.

If you encounter this, please check out: