How to set up a Custom Variable

Custom Variables are a way for you to push data from your website into SessionCam.

You can push as much data across as you want and you can then search for any sessions containing the specific data from within the SessionCam console. This data could be a reference number or any value which is in the datalayer. 

For each Custom Variable you need to define its key and the specific value relevant to the session. 

Follow the script below to set up a Custom Variable: 

<script>
if (!window.sessioncamConfiguration)
window.sessioncamConfiguration = new Object();
if (!window.sessioncamConfiguration.customDataObjects)
window.sessioncamConfiguration.customDataObjects = [];
/** You can edit the values below for key and value to send the data you want**/
var item = {key: "Quote",value: "Generated"};
window.sessioncamConfiguration.customDataObjects.push(item);
</script>

 

In this example, the script sends SessionCam a variable called Quote. This has a value of "Generated".

You can modify this script to send variables that have values that may be dynamic such as a booking reference number.

For example, in the snippet below the code is pulling the reference number from the <span> element. You could also modify this to pull values from a data layer.

<p>This is just a paragraph</p>
<p>Our Ref: <span id="ourRef">123ABC456</span></p>
<p>That was a reference number, it could be a quote or order reference</p>

<script>
if (!window.sessioncamConfiguration)
window.sessioncamConfiguration = new Object();
if (!window.sessioncamConfiguration.customDataObjects)
window.sessioncamConfiguration.customDataObjects = [];
/** You can edit the values below for key and value to send the data you want**/
var item = {key: "QuoteRef",value: document.getElementById("ourRef").innerHTML};
window.sessioncamConfiguration.customDataObjects.push(item);
</script>

Additional variables can be sent by duplicating the last two lines. For example:

<p>This is just a paragraph</p>
<p>Our Ref: <span id="ourRef">123ABC456</span></p>
<p>That was a reference number, it could be a quote or order reference</p>
<p>Quote Total: £<span id="quoteTotal">352.47</span></p>

<script>
if (!window.sessioncamConfiguration)
window.sessioncamConfiguration = new Object();
if (!window.sessioncamConfiguration.customDataObjects)
window.sessioncamConfiguration.customDataObjects = [];
/** You can edit the values below for key and value to send the data you want**/
var item1 = {key: "QuoteRef",value: document.getElementById("ourRef").innerHTML};
var item2 = {key: "QuoteTotal",value: document.getElementById("quoteTotal").innerHTML};
window.sessioncamConfiguration.customDataObjects.push(item1, item2);
</script>

This script can be called to pass through a Custom Variable at any time during the recording of a session.

How to debug a Custom Variable send

In order to check that a Variable is being sent, you can look at the “SaveEvents” calls within your browser’s development tools. In the Form Data area, you will see an item labeled as Tag. The section after is a timestamp, and the next section is the Value. The final section is the Name of the Custom Variable. The different events are separated with a pipe symbol.

 

How to locate a custom variable in the SessionCam console

Setting up a custom variable allows SessionCam to treat that value as it would do an input field. You can user the field value filter to look for your field and the name will be what you have named the 'key' in the code