The end-point that is required for forcing collection can be seen below:
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:
- 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.
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.
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);