1

I need to create a url with Concat function, but also I need to add to this link additional parameters set in the email properties. Therefore, I placed the URL not in the AMPscript block, but in the a tag.

This is my try:

%%[ VAR @url, @subscriber_key, @jobid SET @subscriber_key = _SubscriberKey SET @jobid = JobID ]%%

https://www.pixartprinting.it/unsubscribe/?tk=",@subscriber_key,"&jid=",@jobid)=%%">Unsubscribe_9

Unluckily, it doesn't work: sending a preview and clicking on the resulting link, I receive the horrible error message "bad request - invalid url".

Where am I wrong? Thank you, G.

3 Answers 3

1

The simple solution is to build it all in the ampscript block and then push the value of the final variable into the href. This lets you manipulate all inside the ampscript and reduces the 'inline' coding, especially if you need to place this url in multiple places.

See below for sample of what I mean.

        %%[
        VAR @url, @subscriber_key, @jobid, @finalurl

        SET @subscriber_key = _SubscriberKey
        SET @jobid = JobID 
        SET @url="https://www.pixartprinting.it/unsubscribe/"
        SET @finalurl=CONCAT(@URL,"?tk=",@subscriber_key,"&jid=",@jobid)
        ]%%

        <a href="%%=v(@finalurl)=%%">Unsubscribe9</a>
4

Looks like you are missing a few things.
1 - links using AMPscript tend to work best when wrapped with RedirectTo()
2 - double quotes in the function will cause it to break if you are not also including an escape
3 - there's no Concat() in the snippet provided

Try the following:

%%[
    VAR @url, @subscriber_key, @jobid 
    SET @subscriber_key = _SubscriberKey 
    SET @jobid = JobID 
]%%

<a href="%%=RedirectTo(Concat('https://www.pixartprinting.it/unsubscribe/?tk=',@subscriber_key,'&jid=',@jobid))=%%" target="_blank">Unsubscribe_9</a>
3
  • Thank you @edu8rdo. One more doubt. setting additional email properties on email leve, they will be added also to the link wrapped in RedirectTo()? Jun 25, 2015 at 15:05
  • Yep - as long as those parameters are part of the URL, the yes - the parameters should live w/in the RedirectTo() function. Jun 26, 2015 at 18:49
  • The RedirectTo() just saved my day when trying to create dynamic invitations for Trustpilot. Thank you! Sep 21, 2017 at 9:11
0

Check this example code to compose a complete SF URL in Apex Code:

String sbaseURL = System.URL.getSalesforceBaseUrl().toExternalForm();

sfullURL = sbaseURL + '/apex/' + [VISUALFORCE_PAGE_NAME] + '&' + [PARAMETER_NAME] >+ '=' + [PARAMETER_VALUE];

Regards. David Lirio

You must log in to answer this question.

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