Using "Custom Tags" [CCT_TAGNAME] in Subject

Hello,

I need to use Custom Tags in the subject of Emails but it doesn't seem to work. The sent out email just shows the [CCT_TAGNAME] in the title and not the content of the custom tag. Also tried "List custom fields" like [FIRSTNAME] in the email subject and they are working fine.

Maybe I did something wrong. Can you help me please and give me a short instruction how to use "Custom Tags" in email subject.

Thank you.
 
When creating your emails make sure you click Available Tags when your on the Campaign Template and your tag is showing in the list.

Please confirm.

Also make sure that the user you sent the email to has a value for those tags.
 
Thank you sendmedialtd for your fast reply but yes, it seems that only "list custom field tags" are working in the email subject.

As @sendmedialtd says :)
And also keep in mind that CCT_ tags are only used in the email body.

Ok, thanks for your answer. But is there a way to use CCT_tags in the subject anyway? E.g. copy the function that parses the CCT_tags within the body also to the subject input field?

Would urgently need to use CCT_tags in the subject line.

Thank you.
 
@morpheus93 - please open /apps/common/components/helpers/CampaignHelper.php and make the parseContent (around line 33) method look like this:
PHP:
public static function parseContent($content, Campaign $campaign, ListSubscriber $subscriber, $appendBeacon = false, DeliveryServer $server = null)
{
    $content = StringHelper::decodeSurroundingTags($content);
    $options = Yii::app()->options;

    $searchReplace = self::getCommonTagsSearchReplace($content, $campaign, $subscriber, $server);
    $content       = str_replace(array_keys($searchReplace), array_values($searchReplace), $content);
    $content       = self::getTagFilter()->apply($content, $searchReplace);

    $to      = isset($searchReplace['[CAMPAIGN_TO_NAME]']) ? $searchReplace['[CAMPAIGN_TO_NAME]'] : '';
    $subject = isset($searchReplace['[CAMPAIGN_SUBJECT]']) ? $searchReplace['[CAMPAIGN_SUBJECT]'] : '';

    // tags with params, if any...
    $searchReplace  = array();
    if (preg_match_all('/\[([a-z_]+)([^\]]+)?\]/i', $content, $matches)) {
        $matches = array_unique($matches[0]);
        foreach ($matches as $tag) {
            if (strpos($tag, '[DATETIME') === 0) {
                $searchReplace[$tag] = self::parseDateTimeTag($tag);
            } elseif (strpos($tag, '[DATE') === 0) {
                $searchReplace[$tag] = self::parseDateTag($tag);
            }
        }
    }

    /**
     * This is where we replace the markers from CampaignHelper::transformLinksForTracking() 
     * This is the only place to replace the markers that won't affect the performance 
     * 
     * @since 1.4.3
     * @see CampaignHelper::transformLinksForTracking()
     */
    if (!empty($server)) {
        if ($server->type == 'elasticemail-web-api' || preg_match('/smtp(\d+)?\.elasticemail\.com/i', $server->hostname)) {
            $unsubscribeTags = array('_UNSUBSCRIBE_URL_', '_DIRECT_UNSUBSCRIBE_URL_');
            foreach ($unsubscribeTags as $unsubscribeTag) {
                $pattern = sprintf('/data-unsubtag="%s" href(\s+)?=(\s+)?(\042|\047)((\s+)?(.*?)(\s+)?)(\042|\047)/i', $unsubscribeTag);
                if (!preg_match_all($pattern, $content, $matches)) {
                    continue;
                }
                $pattern = '/href(\s+)?=(\s+)?(\042|\047)((\s+)?(.*?)(\s+)?)(\042|\047)/i';
                $markup  = array_unique($matches[0]);
                foreach ($markup as $mkp) {
                    $_mkp = str_replace(sprintf('data-unsubtag="%s"', $unsubscribeTag), '', $mkp);
                    $_mkp = trim($_mkp);
                    $_mkp = preg_replace($pattern, 'href="{unsubscribe:$6}"', $_mkp);
                    $searchReplace[$mkp] = $_mkp;
                }
            }
        }
    }
    //
    
    if (!empty($searchReplace)) {
        $content = str_replace(array_keys($searchReplace), array_values($searchReplace), $content);
    }
    
    // 1.4.4 -- ADD START
    if (!empty($subject)) {
        $searchReplace = self::getCommonTagsSearchReplace($subject, $campaign, $subscriber, $server);
        $subject       = str_replace(array_keys($searchReplace), array_values($searchReplace), $subject);
    }
    // ADD END
    
    unset($searchReplace);

    if ($appendBeacon && !empty($subscriber->subscriber_id)) {
        $beaconUrl = $options->get('system.urls.frontend_absolute_url');
        $beaconUrl .= 'campaigns/' . $campaign->campaign_uid . '/track-opening/' . $subscriber->subscriber_uid;
        $beaconImage = CHtml::image($beaconUrl, '', array('width' => 1, 'height' => 1));
        $content = str_ireplace('</body>', $beaconImage . "\n" . '</body>', $content);
    }
    
    return array($to, $subject, $content);
}
Then save the file and try again.
 
@morpheus93 - please open /apps/common/components/helpers/CampaignHelper.php and make the parseContent (around line 33) method look like this:
PHP:
public static function parseContent($content, Campaign $campaign, ListSubscriber $subscriber, $appendBeacon = false, DeliveryServer $server = null)
{
    $content = StringHelper::decodeSurroundingTags($content);
    $options = Yii::app()->options;

    $searchReplace = self::getCommonTagsSearchReplace($content, $campaign, $subscriber, $server);
    $content       = str_replace(array_keys($searchReplace), array_values($searchReplace), $content);
    $content       = self::getTagFilter()->apply($content, $searchReplace);

    $to      = isset($searchReplace['[CAMPAIGN_TO_NAME]']) ? $searchReplace['[CAMPAIGN_TO_NAME]'] : '';
    $subject = isset($searchReplace['[CAMPAIGN_SUBJECT]']) ? $searchReplace['[CAMPAIGN_SUBJECT]'] : '';

    // tags with params, if any...
    $searchReplace  = array();
    if (preg_match_all('/\[([a-z_]+)([^\]]+)?\]/i', $content, $matches)) {
        $matches = array_unique($matches[0]);
        foreach ($matches as $tag) {
            if (strpos($tag, '[DATETIME') === 0) {
                $searchReplace[$tag] = self::parseDateTimeTag($tag);
            } elseif (strpos($tag, '[DATE') === 0) {
                $searchReplace[$tag] = self::parseDateTag($tag);
            }
        }
    }

    /**
     * This is where we replace the markers from CampaignHelper::transformLinksForTracking()
     * This is the only place to replace the markers that won't affect the performance
     *
     * @since 1.4.3
     * @see CampaignHelper::transformLinksForTracking()
     */
    if (!empty($server)) {
        if ($server->type == 'elasticemail-web-api' || preg_match('/smtp(\d+)?\.elasticemail\.com/i', $server->hostname)) {
            $unsubscribeTags = array('_UNSUBSCRIBE_URL_', '_DIRECT_UNSUBSCRIBE_URL_');
            foreach ($unsubscribeTags as $unsubscribeTag) {
                $pattern = sprintf('/data-unsubtag="%s" href(\s+)?=(\s+)?(\042|\047)((\s+)?(.*?)(\s+)?)(\042|\047)/i', $unsubscribeTag);
                if (!preg_match_all($pattern, $content, $matches)) {
                    continue;
                }
                $pattern = '/href(\s+)?=(\s+)?(\042|\047)((\s+)?(.*?)(\s+)?)(\042|\047)/i';
                $markup  = array_unique($matches[0]);
                foreach ($markup as $mkp) {
                    $_mkp = str_replace(sprintf('data-unsubtag="%s"', $unsubscribeTag), '', $mkp);
                    $_mkp = trim($_mkp);
                    $_mkp = preg_replace($pattern, 'href="{unsubscribe:$6}"', $_mkp);
                    $searchReplace[$mkp] = $_mkp;
                }
            }
        }
    }
    //
   
    if (!empty($searchReplace)) {
        $content = str_replace(array_keys($searchReplace), array_values($searchReplace), $content);
    }
   
    // 1.4.4 -- ADD START
    if (!empty($subject)) {
        $searchReplace = self::getCommonTagsSearchReplace($subject, $campaign, $subscriber, $server);
        $subject       = str_replace(array_keys($searchReplace), array_values($searchReplace), $subject);
    }
    // ADD END
   
    unset($searchReplace);

    if ($appendBeacon && !empty($subscriber->subscriber_id)) {
        $beaconUrl = $options->get('system.urls.frontend_absolute_url');
        $beaconUrl .= 'campaigns/' . $campaign->campaign_uid . '/track-opening/' . $subscriber->subscriber_uid;
        $beaconImage = CHtml::image($beaconUrl, '', array('width' => 1, 'height' => 1));
        $content = str_ireplace('</body>', $beaconImage . "\n" . '</body>', $content);
    }
   
    return array($to, $subject, $content);
}
Then save the file and try again.
That didn't work for me :(! I copied the content in notepad++ and pasted this text. is there something else I should do?
 
That didn't work for me :(! I copied the content in notepad++ and pasted this text. is there something else I should do?

As far as I know this should work since version 1.4.4 of MW "out of the box". changelog: "
[IMP] - CCT_* tags are now parsed in the campaign subject too
"
 
I was also trying to use the below tag for the subject but it does not appear to be working.
[XML_FEED_ITEM_TITLE]

Is this RSS tag only available in the body?

Is there a way to also make this work in the subject?
Thanks in advance!
 
@twisted1919 thanks for the quick reply. The tag itself didn't work in the subject line.
I had to use this in the subject [XML_FEED_BEGIN url='https://www.mydomain/feed/' count='1'][XML_FEED_ITEM_TITLE][XML_FEED_END]

Once we added this it worked.

Thanks!
 
It will work in subject as well.

Lol you know how I am by now!! Lol, to clarify [XML_FEED_ITEM_TITLE] will work in the subject? If not, any ideas on what I could do for this? My goal is to create an RSS feed setup that automatically sends my daily emails; with the subject being the latest post title!
 
Back
Top