How to set up a Custom Variable based on a Query String value

You can import query string data into SessionCam using Custom Variables. This means you can segment traffic by Query String data like marketing tracking codes.

Below is an example of a modified version of the default custom variable code. It imports the value of s= in the query string (if found) and then you can select it as a Custom Variable.

If a visitor went to, source would have the value of xyz. You can tweak this code to specify relevant query strings and send accordingly.

<script type="text/javascript">

function getQueryString(key) {
var value = "";
var url = window.location.href.toLowerCase();
var start = url.indexOf(key.toLowerCase() + "=");
if (start > -1) {
var temp = url.substring(start + key.length + 1);
var end = temp.indexOf("&");
if (end < 0)
end = temp.indexOf("#");
if (end < 0)
value = temp;
value = temp.substring(0, end);
return value;

var QueryString = getQueryString('s');
if (QueryString != "") {
if (!window.sessioncamConfiguration)
window.sessioncamConfiguration = new Object();
if (!window.sessioncamConfiguration.customDataObjects)
window.sessioncamConfiguration.customDataObjects = [];
key: "source",
value: QueryString