0

So this is essentially the same question as AMPscript Variables in Preheader. However, when I follow the individual's steps, I'm still not able to populate the dynamic preheader. In fact, now I can't seem to get my dynamic subject to populate. In preview in Email Studio, it looks fine, however when I send it the subject line appears as =v(@Subject)=%%.

Clearly, I'm missing something, I just can't seem to figure out what. I put my block AMPscript (below) at the top of the email in a code snippet. Is it because I'm looking up the values in a non-sendable Data extension?

%%[ 

Var @Subscriber_Key, @Premise_Number, @Campaign_ID, @Preferred_Language, @first_name, @debtor_number, @RAF_ID, @preheader, @Subject
Var @rows, @row 

Set @Subscriber_Key = AttributeValue("Subscriber_Key") 
Set @Premise_Number = AttributeValue("Premise_Number") 
Set @Campaign_ID= AttributeValue("Campaign_ID") 

Var @rows1, @row1 

Set @rows1 = LookupRows ("DE_TX_Welcome_Series_PROD_DE", "Subscriber_Key", @Subscriber_Key , "Premise_Number", @Premise_Number, "Campaign_ID", @Campaign_ID) 

if RowCount (@rows1) > 0 then 
  Set @row1 = Row (@rows1,1) 
  Set @RAF_ID = Field(@row1,"RAF_ID") 
endif

Var @rows2, @row2 
Set @rows2 = LookupRows ("DE_Master_DE", "Subscriber_Key", @Subscriber_Key) 

if RowCount (@rows2) > 0 then 
  Set @row2 = Row (@rows2,1) 
  Set @First_Name = Field(@row2,"First_Name") 
  Set @Preferred_Language = Field(@row2,"Preferred_Language")
  Set @debtor_number = Field(@row2, "debtor_number") 
endif


IF @Preferred_Language == "ENGLISH" THEN 
  SET @Subject = "Welcome to company"
  SET @Preheader = "Learn about all the benefits of being a company customer"
ELSEIF @Preferred_Language == "SPANISH" then 
  set @Subject = "Bienvenido a company" 
  Set @Preheader = "Conozca todos los beneficios de ser un cliente de company"
endif

]%%
5
  • 2
    the issue regarding =v(@Subject)=%% is because you are doing a test send and the [TEST]. is running into your ampscript [TEST]%%=v(@subjectline)=%%. you'll need to add a space of remove the bracket
    – EazyE
    Commented Oct 1, 2020 at 14:02
  • regarding preheader where is this code? help.salesforce.com/apex/…
    – EazyE
    Commented Oct 1, 2020 at 14:04
  • Okay I see that now. Removed the bracket. In regards to the code, I attempted to put it in my email. I'm using a combination of content blocks and HTML blocks, so it isn't one solid piece of HTML code. Would I need to input the code into one solid HTML piece and then insert the recommended code? I tried inserting it as an HTML block right after the block ampscript, but it didn't seem to work. Commented Oct 1, 2020 at 15:36
  • 1
    You need to ensure your preheader variable is set before the opening <body> tag Commented Oct 1, 2020 at 17:48
  • So SF got back to me on this one. I was/am utilizing a content-block email with locked code. In order to insert the Preheader Ampscript, I would have to utilize a completely HTML-based email and then insert the code. Commented Oct 1, 2020 at 18:20

1 Answer 1

1

So SF got back to me on this one. I was/am utilizing a content-block email with locked code. In order to insert the Preheader Ampscript, I would have to utilize a completely HTML-based email and then insert the code found in the documentation. You can't do it if you're utilizing content blocks or references within the email itself. https://help.salesforce.com/apex/HTViewSolution?urlname=Preheader-not-displayed-when-using-AMPScript&language=en_US

3
  • 3
    This is not correct. You can use content blocks and references, but these need to be referenced in the template, and not the email itself. As it is only in the template, that you can place content before the <body> tag. Commented Oct 1, 2020 at 19:26
  • @LukasLunow So you would have to create a template, put the Preheader in that template, and then create an email directly from that template? Then you could utilize content blocks? Commented Oct 1, 2020 at 20:38
  • 1
    Yes, correct. You want to have a placeholder or a reference to a content block within the template, above the opening body tag. I would normally use contentblockbykey function to include it in all emails, and allowing you to update it without refreshing the template. Commented Oct 2, 2020 at 9:22

You must log in to answer this question.

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