How to set up Custom Page Names/Paths based on a query string value

You can set your own custom page name and path in SessionCam based on a query string shown in the original page URL. By doing this you can segment traffic by query string data, such as marketing tracking codes.

Below is a modified version of the default Custom Page Name/Path code. It grabs the value of "s=" in the query string (if found) and this is then set as the Custom Page Name or Path.

Using this example, if a visitor went to "www.domain.com/home.htm?s=xyz", "s" would have the value of "xyz". The URL seen by SessionCam would be "www.domain.com/thepagepath/xyz".

You can tweak the code below to specify relevant query strings and set the Page Name/Path accordingly. This script must be executed before the main SessionCam tag.

<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;
    else
      value = temp.substring(0, end);
  }
  return value;
}

//Modify the parameter below to use the QueryString you need. For example your QueryString may be id=1234 then you would need to use id instead of s
var PageName = getQueryString('s');
if (PageName != "") {
  if (!window.sessioncamConfiguration)
    window.sessioncamConfiguration = new Object();
//Modify the line below to set the path as required, you can use '' to send a blank string
  sessioncamConfiguration.SessionCamPath = "thepagepath";
  sessioncamConfiguration.SessionCamPageName = PageName;
}

</script>

This script must be executed before the main SessionCam tag.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.