0

I've figured out how to put in dynamic utm paramters 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 paramters 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 '19 at 13:58
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)=%%

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.