I had a similar need. I had someone build me a Mongo query that I ran directly against Mongo DB, via RoboMongo. Note: This is for Sitecore 8. The structure for Sitecore 9 is different.
This query returns specific goals from the Interactions collection. It then joins with the Contact collection to return the email of the visitor that triggered the goal. This query returns only contacts that have an email address (are known).
// This query returns all the addresses and URL's that match
db.Interactions.aggregate([
// only pages that have at least one Goal Name
// this is to speed up the query
{
$match: { "Pages.PageEvents.Name": "Goal Name" }
}
,
// join with the contacts
{
$lookup:
{
from: "Contacts",
localField: "ContactId",
foreignField: "_id",
as: "contact_email"
}
},
// only look at records that have a email, to shrink after $lookup
{
$match: { "contact_email.Identifiers.Identifier": {$exists:true} }
}
,
// We pull out the interesting parts
{
$project:
{
"Pages.Url.Path": true,
"Pages.PageEvents.Name": true,
"contact_email.Identifiers.Identifier": true,
}
},
{
$unwind: '$Pages'
},
{
// this is the $match to trim after the $unwind
$match: { "Pages.PageEvents.Name": "Goal Name" }
},
{
$project:
{
"Pages.Url.Path": true,
"contact_email.Identifiers.Identifier": true,
}
},
])
If you follow the structure, you should be able to add whatever facet attributes you like.