[SalesForce] Concat and additional parameters

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.

Best Answer

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>
Related Topic