4

How can i retrieve, count of unique visitors and total visitors who have visited a Sitecore site in a month , using experience database.

4

To get the total number of visitors for a month you can use the MongoDb data. Here is an example:

//Connecting to the Analytics DB
var driver = Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbDriver.FromConnectionString("analytics");

//Building our query
var builder = new QueryBuilder();
var filter = builder.And(
    builder.GTE(_ => _.StartDateTime, 
                DateTime.Now.AddDays(-30)), 
                builder.EQ(_ => _.SiteName, 
                siteName.ToLower())); 

//Retrieving data from the "Interactions" collection
var interactions = driver.Interactions.FindAs(filter)

That should give you all visits for the last 30 days. It should give you a starting point to then calculate unique visitors etc...

Code sample taken from this blog post: http://sitecorepro.blogspot.com.by/2015/06/starting-with-sitecore-analytics.html by Konstantin Cherkasov

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.