Welcome

The Cubed tag is to be used inline with the Cubed Platform. You should only tag up your website once you have created a Cubed account and configured it correctly with your Goals and Events.

The tag is loaded in asynchronously, meaning it does not affect page load time - as the page isn't waiting for a response from our server.
Once the tag has arrived on the page, it looks for the vscr object and runs all internal commands.

With this in mind, we recommend that because you do not know when the tag has downloaded you should always reference the vscr object as follows:

var vscr = window.vscr || [];

The idea here is that you treat the vscr object as an array. When our tag loads in, it will continue to treat the vscr object as an array.


Base Tag

Here is an example of the base, and how it should be added to your site. To read more about the base tag and how to configure it please read more here.

<script>
    (function() { 
        var script = document.createElement("script"); 
        script.type = "text/javascript"; 
        script.async = true; 
        script.src = "//d2hkbi3gan6yg6.cloudfront.net/visscore.tag.min.js"; 
        var s = document.getElementsByTagName("script")[0]; 
        s.parentNode.insertBefore(script, s); 
    })(); 
    window.vscr = window.vscr || []; 
    vscr.push(["setAccount", "<account token>"]); 
</script>

The Cubed tag will only fire when it is told to do so, via the fire command:

window.vscr = window.vscr || [];
vscr.push(["fire"]);

The fire command must be triggered post the base tag, in order to send the base tag to our servers.

We've set the vscr to be an array, and pushed a string to it containing the command Fire.


Tag Life Cycle

With this basic setup in mind, the recommended implementation of the Cubed tag is as follows:

  1. On Page Load - Insert base tag snippet
  2. Set Account token
  3. Do page relevant actions (including but not limited to: add events, labels etc...)
  4. Fire

If you have a dynamic action to track, the most obvious being an onclick event handler.
Then the process is the same:

  1. On Page Load - Insert base tag snippet
  2. Set Account token
  3. Do page relevant actions (Add onclick event, see Step 5)
  4. Fire
  5. OnClick - Add Event, and Fire

The important part to note here is that on page load, we still load the tag and did all page actions as normal. We also still called Fire, as we want the page view regardless if the user clicks the button. Step 5 is fired when the user clicks, and we send a Custom Event with the next tag Fire.