0

I have created a goal and triggering it from client side(onclick of anchor) .Now i would like to generate some detailed report using the custom data

var registerTheGoal = new PageEventItem(goalItem); var eventData = page.Register(registerTheGoal); eventData.Data = "Custom Data";

Could some one please provide me the script ,which i can use in Experience Extractor or direct query in MongoDB (I am using Robo mongo)

Thanks in Advance!!

3

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.

  • hey James thank you so much for the answer ,is there any way i can group by cutom data in mongo DB ? – user3621 Aug 5 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.