Decibel Insight

Forcing Collection

Using the Decibel Insight JavaScript API, it is possible to force specific sessions to be collected, regardless of whether they were automatically selected to be included in the sample.

The following example shows a session being marked for collection following a checkout button being clicked on the website:

<script type="text/javascript">
   var buttonEl = document.querySelector('#checkoutButton');
   buttonEl.addEventListener('click', function(){
      decibelInsight('setCollection', true);

In this example, the setCollection JavaScript API end-point is used, which will result in the pageviews from this point forward in the journey being collected.

You can use the setCollection JavaScript API to force collection on all relevant journeys on your property. For example, you may have a 20% sample rate for your property, but want to collect all journeys that reach your checkout. You can use the setCollection call on the Checkout page which would force collection from this point onward for those who were previously being sampled out, while those already in the sample will continue to be collected.

Please note: Upon calling setCollection, this will proceed to collect the user for the remainder of their session and potentially future sessions, see below for further info. If you trigger the setCollection call on a particular part of a flow, for example a Checkout page onwards, or Step 3 of a Sign Up flow, if the user goes back to a previous point, i.e. from checkout to a product page, or step 3 back to step 2, they will continue to be collected.


Further Examples

A few more examples can be seen below. More information can be found in the Sampling Functions section of the Decibel Insight Implementation Guide, which can be found at any time in the app by going to Help > Implementation Guide.

// Enable collection for the current session and future sessions for the current visitor.
decibelInsight('setCollection', true);

// Enable collection for the current session and keep the visitor in the sample for up to three days.
decibelInsight('setCollection', true, 259200);

// Disable collection for the current session only.
decibelInsight('setCollection', false, false);