Decibel Insight

Forcing Collection

One of the criteria of implementations can be the need to be able to collect particular sessions that may fall outside of the standard sampling method. This can be achieved by making use of the Decibel setCollection JavaScript end-point, which will ensure that if a users’ session is not in the sample, and therefore not being collected, it will begin to be collected from the point of calling the end-point.

The end-point that is required for forcing collection can be seen below:

<script type="text/javascript">
decibelInsight('setCollection', true);

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.

Meanwhile, 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 order to test if triggering setCollection has been successful, you can do this by using the Decibel Google Chrome extension. Ensure you have Logging Enabled and are logged into the Decibel platform within the same browser session as your testing.

Upon triggering the setCollection in testing, you will see a Decibel log printed to the console, such as in the second line of the below image.

Further Examples

A few more examples can be seen below.

// 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);