I searched the whole internet for the solution. Can't find it anywhere. Hopefully you guys can help me. I an Ampscript look I am trying to generate a dynamic URL + the actual HTML tags around it. I managed to get the actual URL, but it won't in anyway concat correctly with the HTML tags.
Here is the part of the code that is not generating the correct HTML link:
%%[ SET @clubId = "0015800000c14RRAAY"SET @clubName = "Test Club" SET @withoutTreatAsContent = CONCAT("%", "%=RedirectTo(CloudPagesURL(5697,", "'clubId',", "'", @clubId, "'", ", 'clubName',", "'", @clubName, "'", "))=%", "%"))SET @withTreatAsContent = TreatAsContent(CONCAT('%', '%=RedirectTo(CloudPagesURL(5697,', '"clubId",', '"', @clubId, '"', ', "clubName",', '"', @clubName, '"', '))=%', '%'))SET @URLwithoutTreatASContent = CONCAT('<div><a href="', TreatAsContent(@withoutTreatAsContent), '">', @clubName, '</a></div>')SET @URLwithTreatAsContent = TreatAsContent(CONCAT('<div><a href="', @withTreatAsContent, '">', @clubName, '</a></div>')) ]%%withoutTreatAsContent = %%=v(@withoutTreatAsContent)=%% <br>withTreatAsContent = %%=v(@withTreatAsContent)=%% <br><br>URLwithoutTreatASContent = %%=v(@URLwithoutTreatASContent)=%% <br>URLwithTreatASContent = %%=v(@URLwithTreatASContent)=%% <br>
The output is:
withoutTreatAsContent = %%=RedirectTo(CloudPagesURL(5697,'clubId','0015800000c14RRAAY', 'clubName','Test Club'))=%%withTreatAsContent = https://www.cloudpage.com/NameOfCloudpage?qs=deb490c5bcc970037be9222680c4e82b8b3921a1fdc4c99ff273316a0f0a4264937910bcf80f5f9c0f67b959bec666ad
(don't mind the start URL of the withTreatASContent variable. I changed it due to privacy reasons.)
But when it comes to the actual links it shows:
URLwithoutTreatASContent = Test ClubURLwithTreatASContent = Test Club
And when I use the Chrome inspector it outputs as below for both URLwithoutTreatASContent and URLwithTreatASContent:
<div><a>Test Club</a></div>
The desirable outcome should be:
<div><a href="%%=RedirectTo(CloudPagesURL(5697,'clubId','0015800000c14RRAAY', 'clubName','Test Club'))=%%">Test Club</a><div>
So the word "Test Club" should be a clickable link to the Cloudpage with sending the clubId and clubName parameters over.
I tried many of the above variations and spent over 4 hours figuring this out without any success. Can someone explain to me how I can make this work?