Use the UserIQ library file to check if the user is in scope for active Engagements
Purpose
Allow clients with protected context, browser extensions, non-standard web applications, mobile devices or workspace applications to request if the current product user is in scope for any engagements.
Implementation
You can use this feature at any point in time by using the following JavaScript in your application. The only dependency is the Useriq.js file which is requested by your UserIQ tracking code. At any point in time UserIQ makes library functions available to clients under the JavaScript object “Useriq”. The request passes exposed user data to the UserIQ API for evaluation and response. The method creates a promise object that it uses to evaluate the response when it returns. If the response states that an active engagement exists it will follow up by requesting the engagement in a single script tag. These files are self contained and namespaced so they will neither pollute client applications nor require dependencies. The only restriction is access to JavaScript that abides by the ECMAScript 5 standard which covers 97.65% of global browser usage. See http://caniuse.com/#feat=es5 for more information
Static request method
/**
* Send request to API to check if user is in scope for a engagement
* Optionally pass engagement type and engagement id to limit scope further
*
* @param string type (optional)
* @param mixed engagement_id (optional)
*/
Useriq.useriqTracker.checkForCampaigns(type, campaign_id)
Dynamic request method
_uiq.push([“checkForCampaigns”])
Unsure which method to use? If you know the Useriq object exists you might as well use the static method. If you are not sure when the load sequence happens for your code relative to UserIQ’s code you should use the dynamic method. The API request passes along the most recent user data to facilitate real time evaluation. If a message is in scope the API returns a resolved JavaScript Promise object that then adds a script URL to document with the personalized user message.
Remove Assets
_uiq.push([“removeAssets”]) or Useriq.useriqTracker.removeAssets()
Removes all known assets related to UserIQ engagements. This includes DOM nodes & eventListeners, style tags, script tags, and images.

Comments
0 comments
Please sign in to leave a comment.