The following SessionCam API methods allow you to perform additional functions with the main SessionCam tag.
This article is aimed at developers who are familiar with advanced SessionCam configurations and the custom JS API. If you’re uncertain about any aspect of using custom JS APIs, please contact our support team on support@sessioncam.com for advice before you read on.
sessionCamRecorder
This is the SessionCam Recorder Object that holds all of the data SessionCam uses to perform its functions. Most of the items in this object will not be useful for your use, but we have provided many methods that you can use to create events in SessionCam. These are listed below:
.createVirtualPageLoad(path)
For example:
sessionCamRecorder.createVirtualPageLoad('virtual/testpage');
Returns: null
Effect: if recording is active a virtual page load is created in the current session.
Full help article: https://help.sessioncam.com/hc/en-gb/articles/360001022493-How-to-track-Dynamic-Steps-in-a-One-Page-Process-Virtual-Page-Loads-
.closeVirtualPage()
For example:
sessionCamRecorder.closeVirtualPage();
Returns: null
Effect: closes any current virtual page and continues recording against the previous page. This may be another virtual page (if more than one call to createVirtualPageLoad was previously made) or the previous non-virtual page.
Multiple calls to createVirtualPage produces a stack of these and the last one is removed on each call to closeVirtualPage, reactivating the previous one, until there are none left and the main page is reactivated.
If closeVirtualPage is called when there’s no current virtual page then it won’t do anything.
Full help article: https://help.sessioncam.com/hc/en-gb/articles/360001022493-How-to-track-Dynamic-Steps-in-a-One-Page-Process-Virtual-Page-Loads-
.getSessionCamUserId()
Returns: guid identifying the user across hostnames or blank string if none or null if internal problem
Side effects: if a guid is returned then a cookie sc.UserId is created with that value set for 8760 hours (1 year) and the same value will be returned in the future from the same browser for any site if the cookie is not cleared.
.sendCustomDataEvent(key,value)
For example:
sessionCamRecorder.sendCustomDataEvent('Message', 'Hello');
Returns: null
Effects:
- if recording is in progress generates and sends an event of type CustomDataEvent (code 'tag') using key as the elementId and value as the data
- if a survey configuration is present for the current page and a survey has popped up either on the current page or a previous page in the same session then sends custom data to the surveys host
Either, both or neither of the above can occur as applicable.
Full help article on custom data events: https://help.sessioncam.com/hc/en-gb/articles/360001041714-How-to-set-up-a-Custom-Variable
.sessionId()
For example:
sessionCamRecorder.sessionId()
Returns: current sessionId guid and start time from config, comma separated
For example: a59a3aee-a5e3-4721-bc2e-1e6706b1c04c,635092107600000000.
Side effects: none
Full help articles:
How to Launch a Recording Directly From Your Browser
.registerFields(fieldsSelector, functions)
Parameters:
- 'fieldsSelector': jQuery selector for 0 or more fields
- functions: unlimited number of functions to be called if the value of any of the fields changes
For example:
sessionCamRecorder.registerFields('#myElement', function(jElement) { console.log('Element has changed - value is now ' + jElement.html()); });
Returns: null
Effect: each time any field selected by the selector passed as 'fieldsSelector' changes, then each of the 'functions' will be called and passed a single parameter being a sessionCamJQuery object containing all the elements currently matched by 'fieldsSelector'
Note: this function may be called any number of times with different parameters. Each call will be handled as an entirely separate (group of) element(s) to monitor.
.getFieldValue(element)
Returns: current "value" of element in a manner specific to its type:
- radio/checkbox return the "value" attribute if checked, blank otherwise
- other input elements and textarea return the current value
- select returns the value of options selected (array in the case of multi-selects)
- all other element types return the innerHTML
For example:
sessionCamRecorder.getFieldValue(document.getElementById('myId'));
Side effects: none
.registeredFieldsGetValue(jElement)
Returns: a string containing the current value (calling getFieldValue, see above, internally) of the elements in jElement which have a current value, comma separated, in a manner specific to the type of each. Note that any blank values are omitted from the list.
For example:
sessionCamRecorder.registeredFieldsGetValue(window.sessionCamJQuery('#myId'));
This can be passed the parameter passed by the recorder to the functions specified in registerFields and it will return the values. For example, if the fields were a group of radios it would return the value of which one was selected.
Side effects: none