Community
Showing results for 
Search instead for 
Do you mean 
Reply

Act emarketing history details format

Accepted Solution Solved
Copper Contributor
Posts: 31
Country: USA
Accepted Solution

Act emarketing history details format

Hello,

 

In the new "Act emarketing Results" history records, there are several different values included in the details field. Is there any documentation for exactly how this information is formatted? We've previously been parsing out the values in the Swiftpage history records, and we'd like to do the same for this new format as well.

 

Thanks,

 

- Rob


Accepted Solutions
Solution
Accepted by sam_raikes (Copper Super Contributor)
‎09-25-2015 03:20 AM
Copper Super Contributor
Posts: 52
Country: United_Kingdom

Re: Act emarketing history details format

[ Edited ]

Hi Rob,

 

As far as I'm aware there's no documentation for this but I wrote something to parse this a couple of weeks ago which you are more than welcome to use.

 

You'll need the following class:

 

public class CampaignResult
{
    public CampaignResult()
    { }
    public CampaignResult(int opens, int clicks, int webviews)
    { Opens = opens; Clicks = clicks; WebViews = webviews; }

public Guid ContactID { get; set; } public DateTime Date { get; set; } public string Subject { get; set; } public string Sent { get; set; } public int Opens { get; set; } public int Clicks { get; set; } public int WebViews { get; set; } public string RecordManager { get; set; } }

 

Then you can use this method to populate a list of CampaignResult.

 

public static List<CampaignResult> getCampaignResults(ActFramework fwk, Contact contact)
{
    //CREATE A LIST TO RETURN
    List<CampaignResult> returnList = new List<CampaignResult>();

    //GET HISTORIES FOR THIS CONTACT
    HistoryList hl = fwk.Histories.GetHistories(null, contact, false);
    foreach (History h in hl)
    {
        //GET THE CORRECT HISTORY TYPES
        if (h.HistoryType.ToString() == "Campaign Results")
        {
            //CLEAN RTF FROM THE REGARDING AND DETAILS
            RichTextBox box = new RichTextBox(); box.Rtf = h.RegardingAndDetails;
            string plainDetails = box.Text;
            box.Dispose();

            //PARSE THE VALUES WE NEED
            int opens = Convert.ToInt32(GetStringBetween(", Opens: ", ", Clicks: ", plainDetails));
            int clicks = Convert.ToInt32(GetStringBetween(", Clicks: ", ", Web Views: ", plainDetails));
            int webv = Convert.ToInt32(plainDetails.Substring(plainDetails.LastIndexOf("Web Views: ") + 11).Trim());
            string subject = GetStringBetween("Subject: ", ", Sent: ", plainDetails);
            string sent = GetStringBetween(" Sent: ", ", Opens: ", plainDetails);

            //BUILD A CAMPAIGNRESULT OBJECT
            CampaignResult cr = new CampaignResult(opens, clicks, webv);
            cr.Date = h.CreateDate;
            cr.Subject = subject;
            cr.Sent = sent;
            cr.RecordManager = h.ManageUserName;
            cr.ContactID = contact.ID;
            
//ADD TO THE LIST returnList.Add(cr); } } //RETURN THE LIST return returnList; }

 Here's a short usage example:

 

ContactList contacts = oActFwk.Contacts.GetContactsByID(sort, guids);
foreach (Contact c in contacts) { //Build a list of CampaignResults for this contact List<CampaignResult> results = CampaignResults.getCampaignResults(oActFwk, c); foreach (CampaignResult result in results) { string messStr = "Subject: " + result.Subject + Environment.NewLine + "Sent: " + result.Sent + Environment.NewLine + "Opens: " + result.Opens.ToString() + Environment.NewLine + "Clicks: " + result.Clicks.ToString() + Environment.NewLine + "Web Views: " + result.WebViews.ToString() + Environment.NewLine + "Record Manager: " + result.RecordManager + Environment.NewLine + "Date: " + result.Date.ToString() + Environment.NewLine
+ "ContactID: " + result.ContactID.ToString();
MessageBox.Show(messStr, "Campaign Result", MessageBoxButtons.OK, MessageBoxIcon.Information); } }

 

I've attached the whole class to this post.

 

Regards,

 

 

Russell

View solution in original post


All Replies
Solution
Accepted by sam_raikes (Copper Super Contributor)
‎09-25-2015 03:20 AM
Copper Super Contributor
Posts: 52
Country: United_Kingdom

Re: Act emarketing history details format

[ Edited ]

Hi Rob,

 

As far as I'm aware there's no documentation for this but I wrote something to parse this a couple of weeks ago which you are more than welcome to use.

 

You'll need the following class:

 

public class CampaignResult
{
    public CampaignResult()
    { }
    public CampaignResult(int opens, int clicks, int webviews)
    { Opens = opens; Clicks = clicks; WebViews = webviews; }

public Guid ContactID { get; set; } public DateTime Date { get; set; } public string Subject { get; set; } public string Sent { get; set; } public int Opens { get; set; } public int Clicks { get; set; } public int WebViews { get; set; } public string RecordManager { get; set; } }

 

Then you can use this method to populate a list of CampaignResult.

 

public static List<CampaignResult> getCampaignResults(ActFramework fwk, Contact contact)
{
    //CREATE A LIST TO RETURN
    List<CampaignResult> returnList = new List<CampaignResult>();

    //GET HISTORIES FOR THIS CONTACT
    HistoryList hl = fwk.Histories.GetHistories(null, contact, false);
    foreach (History h in hl)
    {
        //GET THE CORRECT HISTORY TYPES
        if (h.HistoryType.ToString() == "Campaign Results")
        {
            //CLEAN RTF FROM THE REGARDING AND DETAILS
            RichTextBox box = new RichTextBox(); box.Rtf = h.RegardingAndDetails;
            string plainDetails = box.Text;
            box.Dispose();

            //PARSE THE VALUES WE NEED
            int opens = Convert.ToInt32(GetStringBetween(", Opens: ", ", Clicks: ", plainDetails));
            int clicks = Convert.ToInt32(GetStringBetween(", Clicks: ", ", Web Views: ", plainDetails));
            int webv = Convert.ToInt32(plainDetails.Substring(plainDetails.LastIndexOf("Web Views: ") + 11).Trim());
            string subject = GetStringBetween("Subject: ", ", Sent: ", plainDetails);
            string sent = GetStringBetween(" Sent: ", ", Opens: ", plainDetails);

            //BUILD A CAMPAIGNRESULT OBJECT
            CampaignResult cr = new CampaignResult(opens, clicks, webv);
            cr.Date = h.CreateDate;
            cr.Subject = subject;
            cr.Sent = sent;
            cr.RecordManager = h.ManageUserName;
            cr.ContactID = contact.ID;
            
//ADD TO THE LIST returnList.Add(cr); } } //RETURN THE LIST return returnList; }

 Here's a short usage example:

 

ContactList contacts = oActFwk.Contacts.GetContactsByID(sort, guids);
foreach (Contact c in contacts) { //Build a list of CampaignResults for this contact List<CampaignResult> results = CampaignResults.getCampaignResults(oActFwk, c); foreach (CampaignResult result in results) { string messStr = "Subject: " + result.Subject + Environment.NewLine + "Sent: " + result.Sent + Environment.NewLine + "Opens: " + result.Opens.ToString() + Environment.NewLine + "Clicks: " + result.Clicks.ToString() + Environment.NewLine + "Web Views: " + result.WebViews.ToString() + Environment.NewLine + "Record Manager: " + result.RecordManager + Environment.NewLine + "Date: " + result.Date.ToString() + Environment.NewLine
+ "ContactID: " + result.ContactID.ToString();
MessageBox.Show(messStr, "Campaign Result", MessageBoxButtons.OK, MessageBoxIcon.Information); } }

 

I've attached the whole class to this post.

 

Regards,

 

 

Russell