Move action data to a different DB as soon as Piwik records it

I have defined a custom event called Btn-click. Now whenever this event occurs I would like to capture and log this into a different database. So I was looking does Piwik expose any hooks for this. Does piwik generate an Event when such a custom action is recorded

Yes, Piwik generates events for each new action. Please create a new dimension: Dimensions: Develop - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3

and then implement the method onNewAction (see example in the guide)