The following example shows a session being marked for collection following a checkout button being clicked on the website:
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.
- status (boolean): New collection status for the current session
- remember (boolean|integer): Whether to remember the collection status for the next session (optional). If true is provided, the status will apply for this and all future sessions. If false is provided, the status will apply for this session only. If an integer value is provided, the status will apply to this session and any future sessions within the provided number of seconds. If not provided, this will default to true.
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);