Comment on page

Cordova SDK

The Javascript Web SDK can be installed in Cordova based Mobile Applications


Paste the given snippet (same as Web SDK) in your app’s /src/index.html file just before closing the body (</body> ) tag.
<script type="text/javascript">
window["gluConfig"] = {
writeKey: "{{WRITE_KEY}}", //provided by CustomerGlu
userIdentification: {
userId: "{{USER_ID}}",
anonymousId: "{{ANNONYMOUS_ID}}",
userToken: "TOKEN" //using this will make writeKey optional
userAttributes: {
gluAttributes: {}, //add CG reserved user properties here (key-value pair)
customAttributes: {} //add all your custom user properties here (key-value pair)
onLoadError: function () { //error handling function if SDK fails to load
<script type="text/javascript">
(()=>{"use strict";!function(){const e=window.gluConfig||{},t=[],o={open:{returnPromise:!0,callMethod:"open"},close:{returnPromise:!1,callMethod:"close"},register:{returnPromise:!1,callMethod:"register"},listenToAnalytics:{returnPromise:!1,callMethod:"listenToAnalytics"},getCampaignDetails:{returnPromise:!0,callMethod:"getCampaignDetails"}},r=["open","close","register","listenToAnalytics","getCampaignDetails"],n={};for(let e=0;e<r.length;e++)n[r[e]]=function(){const n=o[r[e]],;if(n.returnPromise)return new Promise(((e,o)=>{t.push({callMethod:n.callMethod,arguments:s.concat({resolve:e,reject:o}),isPromise:!0})}));t.push({callMethod:n.callMethod,arguments:s})};let s=document.createElement("script");s.type="text/javascript",s.async=!0,s.src="",s.onload=function(){const o=new window.CustomerGlu(e.writeKey,e.userIdentification,e.userAttributes);for(let e=0;e<t.length;e++)o[t[e].callMethod](...t[e].arguments);window.glu=o},s.onerror=function(){if(t&&t.length){for(let e=0;e<t.length;e++)t[e].isPromise&&t[e].arguments[t[e].arguments.length-1]("GLU_SDK_LOAD_ERROR");e.onLoadError&&e.onLoadError()}},document.getElementsByTagName("body")[0].appendChild(s),window.glu=n}()})();
Replace the variables with correct values.
You are now ready to load CustomerGlu UI on your website. You can now use:
  • The Nudges & Entry points section on the dashboard to add dynamic entrypoints like floating launchers, popups, banners, etc.
  • The subsequent SDK Functionality to programmatically load campaigns.

Setting up Screen Names

The dynamic nudges and entrypoints can be launched on particular screens of the app by setting up the screen names (as opposed to Web SDK integration on websites- which uses url paths for the same).
For Android apps, the screen names can be configured in the dashboard in the following format:
For iOS apps, the screen names can be configured in the dashboard in the following format:
where {GUID} is a unique identifier for the app installation and {AppName} is the name of your app
Apart from the screen names, all functionalities of the Web SDK can be used out of the box in your Cordova app, check out docs here.
Last modified 6mo ago