Follow

Using Custom Code

Custom code is used to connect two systems together, which is known as point-to-point integration. Point-to-point integration requires developers to build custom code between numerous applications, systems, data and devices within the enterprise. The advantage of custom code is that it can be used to support any use case and enhance specific parts of your site. The custom code can include any JavaScript that will be executed along with Glia.

It is possible that adding custom code to your site might conflict with existing web page code. Therefore, it is essential that client will perform extensive testing after custom code is implemented. Client has to make sure also IE11 browser is tested as this is one of the most restrictive browsers Glia is supporting. Also, custom code testing should be applied after client side developers make any changes in their website.

The custom JavaScript will be added to the dedicated field in Advanced Admin, under “Developer” tab.

Custom_Javascript.png

 

Common cases when to use Custom Javascript

Analytics events - in order to track conversion, Glia integrates with analytics providers so businesses can measure their KPIs as they relate to their customers’ use of Glia. Following JS example shows how analytics events are sent to Heap:

 __gliaAnalyticsBridge = function(event, payload){

   payload.timestamp = (Date.now());

   if ((typeof(heap) === "object") && (typeof(heap.track) === "function")) {
     gl.logger.log("Glia#Production#CustomCode#gliaAnalyticsBridge fired and tracking Heap event");
     heap.track(event, payload);
   } else {
     gl.logger.log("Glia#Production#CustomCode#salemoveAnalyticsBridge fired and Head did not exist");
   };

   if (typeof(digitalData) === "object"){
     gl.logger.log("Glia#Production#CustomCode#gliaAnalyticsBridge fired and digitalData existed");
     digitalData.utilities.ensightenLog("Glia trigger activated", "log");
     digitalData.eventListeners.getGliaEvent(event, payload);
   } else {
     gl.logger.log("Glia#Production#CustomCode#gliaAnalyticsBridge fired and digitalData did not exist");
   };
 };


Locale changes -  generally locale changes are done via JS SDK, however it is also possible to update locale using custom code calling out the function. See example below:

__gliaLocaleFrench = function(){ gl.getApi({version: 'v1'}).then(function(api){api.setLocale('fr-CA')}); gl.logger.log("l10n file loaded"); };

 

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

Comments