Command queue for embedded web forms
OtSDK Command Queue
To get started, you can run the following script to initialize a command queue. This script will add the OneTrust public API commands and therefore eliminate the dependency of waiting for the SDK/OneTrust object to become available on the page before sending the next command.
Note:
- After a command is processed, the command will be removed from the queue even if there is a failure, and the command will not be processed again.
- It is advised that you initialize the queue before inserting Onetrust SDKs on the page.
Initialize the Command Queue
The following script will initialize the command queue. Ensure that the script is inserted before adding the OneTrust Consent SDK on the page.
<script>
// Initialize the Command Queue
window.OtSdk=window.OtSdk||function(){(OtSdk.q=OtSdk.q||[]).push(arguments)};
</script>
Example Command Calls
The following is an example command queue call.
// Example command queue calls.
// command[0] refers sdk type: 'consent'
// command[1] refers API name
// command[n] Are parameters to the API
// callback function to be passed as a last parameter and it's optional
OtSdk('consent','[ApiName]','{param1}',ApiCallbackFn);
// Example Callback for the command above
function ApiCallbackFn(isSuccess, response) {
if (isSuccess) {
// Success... access the response object
} else {
// Error handling
}
}
Updated 7 months ago