예제 #1
0
        /// <summary>
        /// Returns paramater string for url with utm-tags.
        /// </summary>
        /// <param name="data">Data with utm tags</param>
        /// <returns>String with parameters for url</returns>
        protected static string GetUtmParamString(BulkEmailUtmData data)
        {
            string utmParam = string.Format("utm_source={0}&utm_medium={1}&utm_campaign={2}",
                                            data.UtmSource,
                                            data.UtmMedium,
                                            data.UtmCampaign);

            if (!string.IsNullOrEmpty(data.UtmTerm))
            {
                utmParam += "&utm_term=" + data.UtmTerm;
            }
            if (!string.IsNullOrEmpty(data.UtmContent))
            {
                utmParam += "&utm_content=" + data.UtmContent;
            }
            return(utmParam);
        }
예제 #2
0
        /// <summary>
        /// Appends utm parameters to the email template.
        /// </summary>
        /// <param name="data">Source data of utm parameters.</param>
        /// <param name="bulkEmailRId">RId of the BulkEmail</param>
        /// <param name="unsubscribeMacrosAliases">Collection of the aliases of unsubscribe macros.</param>
        /// <returns>Email template with utm parameters.</returns>
        public static string GetTemplateCodeWithUtmLabel(BulkEmailUtmData data, int bulkEmailRId,
                                                         IEnumerable <string> unsubscribeMacrosAliases = null)
        {
            string        resultTemplateCode = data.TemplateCode;
            List <string> domains            = GetDomainList(data.Domains);
            string        utmParam           = GetUtmParamString(data);
            string        requiredUtmParam   = GetBulkEmailRIdParamString(bulkEmailRId);

            if (unsubscribeMacrosAliases == null)
            {
                unsubscribeMacrosAliases = new string[0];
            }
            Dictionary <string, string> hyperlinks = GetLinksForReplace(domains, data.TemplateCode, data.UseUtm,
                                                                        utmParam, requiredUtmParam, unsubscribeMacrosAliases);

            return(hyperlinks.Aggregate(resultTemplateCode,
                                        (current, hyperlink) => current.Replace(hyperlink.Key, hyperlink.Value)));
        }