JS Tool Documentation

Last updated: March 6th, 2019

Visitor tracking and recognition

The FlowStack jstool is a script which not only tracks web site visitors, but also provides methods for custom tracking, checking against segments and content rendering.

Minimal implementation of the JS Tool

Step One

Insert the FlowStack jstool.js script

Include the jstool:
<script>
    (function(f, l, o, w, s, t, a, c, k) {
      f['FS_CORE_NAME'] = w; f['FS_CORE_DOMAIN'] = s; f['FS_QUEUE'] = [];
      f['fs'] = function(){f['FS_QUEUE'].push(arguments);}
      a = l.createElement(o);
      c = l.getElementsByTagName(o)[0];
      a.async = 1;
      a.src = document.location.protocol + '//' + s + '/' + t;
      c.parentNode.insertBefore(a, c);
    })(window, document, 'script', 'fs', 'jstool.flowstack.com', 'jstool.js')
</script>

Step Two

Initialize the jstool object and create page view event.

Create FS object:
<script>
  fs('init','<accountId>');
  fs('pageview');
</script>

JS Tool methods

The fs object provides various methods

fs(<method>,[params]*)

	//Init the tracker
	fs('init',<accountId>)
	
	//Set a variable
	fs('setVar',<name>,<value>)
	
	//Get a variable
	fs('getVar',<name>,<callback>)
	
	//Track a pageview
	fs('pageview'[,page][,title])
	if [page] is not set window.location.href is used
	if [title] is not set window.title is used
	
	//Add a data tag (used by plugins to add fs-data attributes)
	fs('addDataTag',<name>,<callback>)
	
	//Internal method to run a single tag
	fs('checkTag',[element],<tag>)
	
	//internal method to run all tags
	fs('checkTags'[,element])
                                       
                                       

Segment Module

Loading the segment module to the jstool provides you with method to check if visitor belongs to specific segment(s)


<script src="https://jstool.flowstack.com/segment.js"></script>
                                       

Methods

//Checks if visitor is in one or more segments
	fs('inSegment',<segmentId>,<callback>)
	<segmentId>: segment guid or an array of segments
	<callback>: 
		funtion: calls callback method with result
		string: hides/shows dom element where id="<callback>"
		domElement: hides/shows the dom element
	
	//Checks if visitor is in one or more segments and hides/displays element 
	data-fs-in-segment="<segmentId>"
	<segmentId>: segment guid or array of segment guids
                                       

Content Module

Loading the content module to the jstool provides you with methods render content with visitors corresponding profile data without retrieving profile


<script src="https://jstool.flowstack.com/content.js"></script>
                                       

Methods

//Renders content
	fs('contentRender',<contentId>,<callback>)
	<contentId>: The content guid from flowstack to render
	<callback>:
		function: calls the function with the result
		object: sets the objects innerHTML property to result html
		string: sets the object with the id <callback> to the result html
		
	data-fs-content="<contentId>"
                                       

Content Module

Loading the content module to the jstool provides you with methods render content with visitors corresponding profile data without retrieving profile


<script src="https://jstool.flowstack.com/content.js"></script>
                                       

Methods

//Renders content
	fs('contentRender',<contentId>,<callback>)
	<contentId>: The content guid from flowstack to render
	<callback>:
		function: calls the function with the result
		object: sets the objects innerHTML property to result html
		string: sets the object with the id <callback> to the result html
		
	data-fs-content="<contentId>"
                                       

Permission Module

Loading the segment module to the jstool provides you with methods to alter or see permissions


<script src="https://jstool.flowstack.com/permission.js"></script>
                                       

Methods

//Checks if a visitor has a permission
	fs('permission',<permissionId>,<callback>)
	<permissionId>: the flowstack permission guid
	<callback>: the callback to call with the result
	
	//Links a checkbox to a permission
	fs('permissionCheckbox',<permissionId>,<element>)
	<permissionId>: the flowstack permission guid
	<element>:
		<string>: uses the element with the given id
		<object>: uses the object given
		
	data-fs-permission="<permissionId>"
	//links the given checkbox directly to the permission