0

QUESTION: Is there a way to simulate tags for content in classic content in SFMC?

PURPOSE: Ideally, the goal is to make it easier for a user to dynamically include content depending on which tags are selected.

EXAMPLE: If an email (e.g., 'feb_promo') had the tags 'sale' and 'international', it would know to pull in the Content Areas called 'sale' and 'international', respectively, without having to manually copy/paste the HTML snippets for those sections into every email.

ALTERNATIVES: If there is a more commonly used way that this can be accomplished, please share. Tags (i.e., attributes) seemed pretty straightforward until I realized it just might not have support.

CODE: I'm not a SFMC wiz, so I'm not sure how this would be written in AMPScript. I've constructed the basic logic with Python. In this case, all emails are instantiated with a list of tags supplied by the user (I know they aren't, but this would be the goal). Here, 'feb_promo' is created with the tags 'sale' and 'international'. For each of those user-supplied tags, the appropriate content area is pulled in. I've used basic 'if' statements for simplicity, but this would be abstracted to check for N number of tags among all possible content areas.

class Email():
    def __init__(self, tags=[]):
        self.tags = tags

feb_promo = Email(tags=['sale', 'international'])

for tag in feb_promo.tags:
    if tag == 'sale':
        %%=ContentAreaByName('My Contents\sale')=%%

    if tag == 'international':
        %%=ContentAreaByName('My Contents\international')=%%

1 Answer 1

0

SFMC has a couple of options for accomplishing this.

You can save the "sale" or "international" chunks as either content blocks or code snippets. The nice thing about using either option is you don't have to copy and paste, SFMC gives you the ability to have it in a dropdown so you can plug it in easily.

If you are using mostly templates I would go with the content block option.
Check out: https://support.stackla.com/hc/en-us/articles/115001486474-How-to-create-a-re-usable-Content-Block-in-SalesForce-Marketing-Cloud

If you want to have it be a little more dynamic, the code snippet option is probably a better fit. I tend to use this feature a lot as we do most of our email builds in HTML. The below code block will take the tags and lookup a code block from another reference data extension. Hope it helps send you in the right direction.

%%[ var @emailname, set @emailname = "feb_promo"

var @tags, @tag_string, @each_tag, @tag_block set @tags = Lookup("emailtagsDE","Tags","EmailName",@emailname)

set @tag_string = BuildRowsetFromString(@tags,',') for @i = 1 to Rowcount(@tag_string) do Set @row = Row(@tag_string, @i) Set @each_tag = Field(@row,1) set @tag_block = Lookup("TagReferenceDE","CodeBlock","Tag",@each_tag) ]%% %%= v(@tag_block)=%%
%%[ next @i ]%%

2
  • The OP is about Classic Content. The content block option won't work since this is a feature of Content Builder. We code our emails outside of SFMC, so we've never had a reason to switch to the CB GUI. While your snippet achieves the goal, it makes the process more complex than just manually adding HTML snippets to an email. A separate DE would have to be maintained, and every email would have to be added manually with the appropriate tags. The goal is to make it easier (e.g., for a marketer) to be able to add predefined content when desired without having to ask for the code to be updated.
    – smc5293
    Commented Jan 31, 2018 at 15:59
  • I realized there a much easier way within Content Builder - the tags link to HTML snippets, so you could just build code snippets. They would show in the snippet drop down and you could just pick what you wanted as you build. It lets you edit the code snippet and keep it in your own little repository. I realize this doesn't help you as you are looking for Classic Content, but I wanted to share that in case it helped. Best of luck in solving your question. Commented Jan 31, 2018 at 21:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .