0

The Question(s):

  • Does RedirectTo has to be Inline to work properly?
  • Can RedirectTo be somehow used in AMP-Script Blocks to work as a variable?

My experiment ;D



Works

Inside a ContentBlock in the e-Mail:

Do you want to have a <u><a alias="Cookie" conversion="false" data-linkto="cloudpageslandingpage" href="%%=RedirectTo(CloudPagesURL(404))=%%" style="text-decoration:none;color:#FFFFFF;" title="Cookie">cookie</a></u>?

Works too

%%[
set @cookie_url = CloudpagesURL(404)
]%%

Do you want to have a <u><a alias="Cookie" conversion="false" data-linkto="cloudpageslandingpage" href="%%=RedirectTo(@cookie_url)=%%" style="text-decoration:none;color:#FFFFFF;" title="Cookie">cookie</a></u>?

So this is just an inline call of redirectto and a cloudpagesurl function



Does not work

%%[
set @cookie_alias = "Cookie"
set @cookie_href = RedirectTo(CloudPagesURL(404))

set @cookie_line = Concat("Do you want to have a ",'<a alias="',@cookie_alias,'" conversion="false" data-linkto="cloudpageslandingpage" href="',@cookie_href,'" style="color:#FFFFFF;text-decoration:none;font-weight : bold; " title="cookie">cookie</a>',"?")
]%%

%%=v(@cookie_line)=%%

Does not work either

%%[
set @cookie_alias = "Cookie"
set @cookie_href = RedirectTo(CloudPagesURL(404))
]%%

Do you want to have a <u><a alias="Cookie" conversion="false" data-linkto="cloudpageslandingpage" href="%%=v(@cookie_href)=%%" style="text-decoration:none;color:#FFFFFF;" title="Cookie">cookie</a></u>?


Tried other variations where the RedirectTo function is not inline in the email itself and each time the links will not be tracked inside the tracking tab when doing so.

1 Answer 1

3

As stated in the docs for RedirectTo():

Only use this function in HTML emails within the href attribute of an

(The mistake with the < instead of > is actual a direct quote from the docs)

Or from AMPscript Guide:

This function is required when using the <a> HTML hyperlink tag in emails when the hypertext reference (href) attribute is either an attribute or a variable and the hyperlink is a tracked email link.

If link tracking in an email is not enabled when the email is sent, the RedirectTo function is not required.

If the RedirectTo function is not used in the href attribute when an attribute or variable is used, the hyperlink will not be resolved with the attribute or variable, for example it will appear as, https://click.email.com/%%=v(@url)=%%.

So basically, the first two options you showed are the only viable options. It cannot be used inside an AMPscript block.

1
  • 2
    Another interesting note from the AMPScript Guide: "NOTE: Any code that appears before the Redirect function will be interpreted, but any code that appears after the function will not." Mar 31, 2020 at 12:38

You must log in to answer this question.

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