The full addon approach is at https://developer.atlassian.com/confdev/confluence-plugin-guide/confluence-plugin-module-types/event-listener-module/writing-an-event-listener-plugin-module
But if you're happy installing the script-runner, you can write listeners in there as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.