Questions? Feedback? powered by Olark live chat software

Web Application

Simility provides JavaScript programs to capture data from web applications. The JavaScript programs are of two types: Standard Page Load and Event Trigger. Our Simility engineering team helps you choose the one that best suits your needs. You must copy and paste the corresponding JavaScript program within the body section of individual web pages from which you want to capture the data.

Standard Page Load JavaScript

When a web page including the Standard Page Load JavaScript loads, the JavaScript gets downloaded and triggered to start capturing all actions performed on the web page along with the user details and send the captured data to Simility software.

Script Syntax
<script>
	var similityContext = {
		"customer_id": "<uuid>", 
		"session_id": "<session id>",
		"user_id": "<user_id>",
		"zone": "<zone>",
		"event_types": "<type>"
	};
</script>
<script type="application/javascript" src="https://cdn.simility.com/b.js"></script>
Parameters
Name Type Description
customer_id String Specify the UUID provided by Simility.
session_id String Specify a unique session ID assigned to the user session when a user accessed your application.
user_id String Optional. Specify the currently logged on user ID or email ID in case of anonymous transaction/activities. This can be internal identification you use in your organization.
Zone String Specify the zone where your data centers are hosted.
event_types String Specify the event or action that you want to associate with the JavaScript. You can specify multiple values separated by a comma.
Example
<script>
	var similityContext = {
		"customer_id": "5e295f6c-5fd2-11e7-907b-a6006ad3dba0", 
		"session_id": "lit3py55t21z5v55vlm25s55",
		"user_id": "1200583092",
		"event_types": "user_registration",
		"zone": "us"
	};
</script>
<script type="application/javascript" src="https://cdn.simility.com/b.js"></script>

In case JavaScript is turned off on browsers, the standard page load JS cannot capture the required information from web pages. To record such cases, Simility recommends adding a <noscript> section as well. The <noscript>  section is executed when JavaScript is disabled to run on browsers. You can add the <noscript> section using the following method:

NoScript Tag with Query Parameters

  • Add the following script in the body section of the web page.
    <noscript>
            <img width="1" height="1" alt="" src="https://b-<zone>.simility.com/b.png?c=<customer_id>&si=<customer_session_id>&u=<user_id>">
     </noscript>

    In the above script, replace the customer_id, session_id, and user_id parameters as per the Parameters table above.

Event Trigger JavaScript

Use the Event Trigger JavaScript to trigger the JavaScript execution when an event is performed on the web page, such as when a dialog box opens or on a button click.

You can use the Event trigger JavaScript synchronously and asynchronously.

  • Synchronous: the JavaScript gets downloaded when the web page loads, but gets executed only when the specified event is triggered on the web page.
  • Asynchronous: the JavaScript gets downloaded and executed only when the specified event is triggered.
Do not use the Event Trigger JavaScript for events that redirect to another page (for example, a login event) and might not allow the JavaScript to finish execution.
Synchronous Script Syntax
<script>
	$('#<dialog/action>').click(function() {
		if (window.SimilityScript) {
			var similityScriptContext = {
				"customer_id": "<UUID>", 
				"session_id": "<session ID>",
				"user_id": "<user_id>",
				"zone": "<zone>",
				"event_types": "<type>"
			};
			var ss = new SimilityScript(similityScriptContext);
			ss.execute();
		}
	});
</script>
<script type="application/javascript" src="https://cdn.simility.com/b.js"></script>
Asynchronous Script Syntax
<script>
	$('#<dialog/action>').click(function() {
		$.getScript('https://cdn.simility.com/b.js', function()
		{  
			var similityScriptContext = {
				"customer_id": "<UUID>", 
				"session_id": "<session ID>",
				"user_id": "<user_id>",
				"zone": "<zone>",
				"event_types": "<type>"
			};
			var ss = new SimilityScript(similityScriptContext);
			ss.execute();
		}); 
	});
</script>

In the above syntaxes, replace the <dialog/action> with the name of the dialog box or action – so that the JavaScript gets executed when the specified dialog box (user registration) opens or when the specified action (a button click) is performed.

Parameters
Name Type Description
customer_id String Specify the UUID provided by Simility.
session_id String Specify a unique session ID assigned to the user session when a user accessed your application.
user_id String Optional. Specify the currently logged on user ID or email ID in case of anonymous transaction/activity. This can be internal identification you use in your organization.
Zone String Specify the zone where your data centers are hosted.
event_types String Specify the event or action that you want to associate with the JavaScript. You can specify multiple values separated by a comma.
Synchronous Example
//Button widget with the ID, checkout-button
<button id="checkout-button">Checkout</button>

//JavaScript to execute when the button (checkout-button) is clicked
<script>
	$('#checkout-button').click(function() {
		if (window.SimilityScript) {
			var similityScriptContext = {
				"customer_id": "5e295f6c-5fd2-11e7-907b-a6006ad3dba0", 
				"session_id": "lit3py55t21z5v55vlm25s55",
				"user_id": "1200583092",
				"zone": "us",
				"event_types": "checkout_page"
			};
			var ss = new SimilityScript(similityScriptContext);
			ss.execute();
		}
	});
</script>
<script type="application/javascript" src="https://cdn.simility.com/b.js"></script>
Asynchronous Example
//Button widget with the ID, checkout-button
<button id="checkout-button">Checkout</button>

//JavaScript to download and execute when the button (checkout-button) is clicked
<script>
	$('#checkout-button').click(function() {
		$.getScript('https://cdn.simility.com/b.js', function(){  
			var similityScriptContext = {
				"customer_id": "5e295f6c-5fd2-11e7-907b-a6006ad3dba0", 
				"session_id": "lit3py55t21z5v55vlm25s55",
				"user_id": "1200583092",
				"zone": "us",
				"event_types": "checkout_page"
			};
			var ss = new SimilityScript(similityScriptContext);
			ss.execute();
		}); 
	});
</script>