The addEventListener command can be used to define a callback function that can be used to detect changes in the CMP. The callback shall be called with an EventListener object immediately. Click here for more information on the addEventListener command, in the GPP specification.
Command
__gpp('addEventListener', myFunction);
//Example registers an event listener when a button is clicked on page
function myFunction(EventListener, success) {
console.log("Event listener added:" + success);
console.log(EventListener);
}
...
<button onclick="__gpp('addEventListener', myFunction)">Add event listener</button>
Response
In addition to any custom code you might implement when your function executes, a successful response will return the EventListener object and true for the success parameter.
