+1 vote


Is it possible to get the efficy-ID of a contact inside a flexmail campaign ?



asked in Other by (538 points)

2 Answers

+1 vote

If you want to want to set a custom url with the the Contact Mailingcode inside a Flexmail message, you can use the free_field_5 field, it already contains the mailingcode of the Efficy Contact.

answered by (585 points)
0 votes

Hi Loïc,

If you don't know the preferences or the segment used while sending the campaign, you can use the soap function GetCampaignHistory with the boolean campaignSent of campaignHistoryOptionsType set to true.

Untested example based on flexmailImplementation.GetContactRead (item.ExtKey contains the Flexmail campaignId):

GetContacts: function(item) {
    if (!item.ExtKey) return [];

    pushTag('GetCampaignHistoryReq', 'xsi:type="flex:GetCampaignHistoryReq"');
    pushInt('campaignId', item.ExtKey);
    // Select only read actions to be included in the history
    pushTag('campaignHistoryOptionsType', 'xsi:type="flex:CampaignHistoryOptionsType"');
    pushBoolean('campaignSent', true);

    var i, it, referenceId;
    var xmlDoc = executeSoapRequest(['0'], this._flexInfo);
    var contacts = [];
    var history = xmlDoc.getElementsByTagName('emailAddressHistoryActionTypeItems');

    for (i = 0; i < history.length; i++) {
        it = history[i].childNodes[history[i].childNodes.length - 1];
        referenceId = it.getElementsByTagName('referenceId')[0].text;
        if (referenceId) {
            var kcontact = referenceId.split('_')[0];
            if (contacts.indexOf(kcontact) === -1)

    return contacts;

The referenceId contains the contact key and the emailfield key (K_CONTACT + '_' + PROF_CONT.EMAILFIELD).

We used this kind of function in the v1 of the Flexmail integration but we are now retrieving the contacts based on the segmentId or the preferencesId after creating the campaign and before sending it. The reason of this change is that Flexmail was returning Out of memory error when a lot of contacts were returned (> 50.000 contacts). Sadly, this function does not have a page option.

answered by (585 points)
I missed explains my demand. Inside a flemail message I want to set a custom url with the efficy contact key or the mailingcode.
Welcome to Efficy Overflow, where you can ask questions and receive answers from other members of the community.
1,249 questions
1,521 answers
328 users