0

I've figured out how to put in dynamic utm parameters to append to all links in an email with the below ampscript.

%%[
Var @campaign, @pcode
Set @campaignID = "%%campaignid%%"
Set @pcode = "%%pcode%%"
]%%

My question is - is there a way to add to the ampscript what to fill in for those parameters if those fields don't exist in a customers Profile Attribute.

For example if a customer doesn't have a 'pcode' can i set a default in the ampscript?

1
  • Inside AMPScript Code blocks you should definitely not use stuff like this Set @campaignID = "%%campaignid%%". When these fields are inside a dataexentension you would do it like this: Set @campaignID = [campaignid] if its a subscriber attribute you would use something like Set @campaignID = AttributeValue(campaignid). But i guess it doesnt make any sense to store a campaignid in subscriber attributes :D Oct 31, 2019 at 13:58

1 Answer 1

0

You can use IF/ELSE statements. So, if in an AMPscript block, a rough example would be something like:

%%[
VAR @campaign, @pcode 

SET @pcode = pcode
SET @campaignID = campaignid

IF EMPTY(@pcode) == false THEN
    SET @pcode = pcode
ELSE
    SET @pcode = 'some default text here'
ENDIF
]%%

Output: %%=v(@pcode)=%%

You must log in to answer this question.

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