0

For some reason I can't get a URL to open from a button.

I'm using a code to pull through the a URL from a data extension, each email recipient will receive a unique URL. I can see that the code is working correctly as when I place the %%=V(@CouponCode)=%% field within the body copy I can see the unique URLs but when I use the %%=V(@CouponCode)=%% with the button content block and click it I just get an error "An error has occurred and has been logged by our system. Thank you.".

What am I doing wrong?

1 Answer 1

0

You can see different examples of having a button with a link in Email (will not allow to properly preview Button #4) or CloudPage and only Button #2 and #6 are not working, other variants should be sufficient for you to use:

%%[ SET @link = Lookup("DE_Name", "URL", "Field_identifier", "Value_identifier") ]%%
<body>
        <p>Button #1 - Example of adding an onclick event to the button tag</p>
        <form action="%%=v(@link)=%%" method="post">
            <input type="submit" value="Button #1">
        </form>
    <br/>
        <p>Button #2 - Example of adding an onclick event to the input tag</p>
        <form>
            <input type="button" onclick="%%=v(@link)=%%';" value="Button #2" />
        </form>
    <br/>
        <p>Button #3 - Example of opening a link from a button in a new window</p>
        <form action="%%=v(@link)=%%">
            <button type="submit">Button #3</button>
        </form>
    <br/>
        <p>Button #4 - Example of creating a button acting like a link with the formaction attribute</p>
        <form>
            <button type="submit" formaction="%%=v(@link)=%%">Button #4</button>
        </form>
    <br/>
        <p>Button #5 - Example of opening a link from a button in a new window</p>
        <form action="%%=v(@link)=%%" method="get" target="_blank">
            <button type="submit">Button #5</button>
        </form>
    <br/>
        <p>Button #6 - Example of adding an onclick event to the button tag</p>
        <button onclick="%%=v(@link)=%%">Button #6</button>
</body>

The last, 7th variant also allows you to put %%=v(@link)=%% into the "Link URL" field inside Button properties when you are creating an email via Drag&Drop approach and once clicked open the link.

5
  • This is amazing Button 3 or 5 are working. The only thing happening now is the buttons are not displaying in outlook but will display when you view the email in browser.
    – Cat Wright
    Commented Jul 9, 2021 at 15:14
  • Have you checked if the button is displayed in another client, e.g. Gmail? That could be a problem related to the CSS since simple unstyled HTML from above should be visible everywhere.
    – Niko
    Commented Jul 9, 2021 at 19:29
  • It is visible in Gmail but I will look at the CSS as this is unstyled
    – Cat Wright
    Commented Jul 13, 2021 at 7:55
  • That is another problem to solve already :) If my answer helped you, please choose it.
    – Niko
    Commented Jul 13, 2021 at 8:12
  • Your right Niko and thank you for your help
    – Cat Wright
    Commented Jul 13, 2021 at 8:21

You must log in to answer this question.

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