Create a report for all user ids that has campaign and goal conversion


We need to create a report for all recorded user ids, that also have related campaign and at least one goal conversion for any visit. Is it possible to create custom reports like this from Matomo, or do I need to write some manual SQL to query the database directly? Not sure the report API can do this.

Thanks in advance

This query worked pretty well:

FROM piwik_log_visit v1 
JOIN piwik_log_visit v2 ON v1.idvisitor = v2.idvisitor 
JOIN piwik_log_conversion con ON con.idvisit = v2.idvisit
JOIN piwik_goal gl ON gl.idgoal = con.idgoal
v2.visit_goal_converted = 1 AND
v1.campaign_name = <your campaign name>

I will just make a plugin to get the results.