How to set up a Custom Variable

In this article:

  1. Setting up a Custom Variable
  2. How to debug a Custom Variable send
  3. How to filter by a Custom Variable in SessionCam

Setting 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:

<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: "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 labelled 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. 

mceclip0.png

How to filter by a Custom Variable in SessionCam

Custom Variables are treated in SessionCam like anonymous form fields. You can filter for them by using the Field Value filter in the Advanced Filters.

mceclip1.png

Field Name is your KEY and Field Value is your VALUE.

If you cannot see you KEY auto populating you may need to wait for the session to be processed in SessionCam (usually 20 minutes but we recommend waiting 2 hours), or you may need to test if the value is being sent. See here.

To find more about advanced filters click here.