Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • ewuski 88 posts 234 karma points
    Dec 13, 2023 @ 14:51
    ewuski
    0

    How to add merge fields to button or text link param in email template?

    I am trying to build a transactional email template but we also had the same issue with the campaingn emails:

    When inserting a link inside a text control or a button control in the email template - is it possible to insert a merge field as a parameter? Eg.:

    https://www.mydomain.com?param={productId}

    1. Text link:

    It is possible to select the content and add a query string but the query string pattern is not getting replaced by the merge field value during sending.

    So selecting content then adding

    ?param={{productId}}
    

    in Anchor / querystring field produces this:

    https://www.mydomain.com/?ref=%7B%7BproductId%7D%7D

    2. Button link:

    There are 4 options to insert a value:

    a. Content - not possible to add a query string to the url

    b. Media - not relevant in our case

    c. URL - even if adding this:

    https://www.mydomain.com?param={{productId}} 
    

    the url is getting serialised (as explained above in point 1) and not replacing {{productId}} by a merge value as it does in pure text.

    d. Field - not sure what is does really apart of that we can select the merge field but this option is not building any button url.

    So basically the question is - how to add a merge field as a param or part of the link in email body or as an email button value?

    Because it makes marketing difficult if we cannot direct a user to the right page straight from the email body.

  • Markus Johansson 1911 posts 5757 karma points MVP c-trib
    Dec 15, 2023 @ 01:01
    Markus Johansson
    0

    Hi!

    Thank you for your questions and feedback!

    It seems like the use case that you have is not supported out of the box today. However, I really think that we should support this so I need to investigate further and provide fixes for this in an upcoming release.

    Tested this and you are right, one can use the "Anchor / querystring"-feature to append to the selected URL but it does not really work as one would want.

    I think that the fact that the brackets get encoded is why this is happening in both your cases - I need to check.

    The "Field" option is used if you provide a full link as a merge field which is probably possible in many cases.

    Do you know the link at the time when you trigger the transactional email? In that case you could create a property on the email model that contains the full link - this could then be used in the "Field"-option for buttons.

    You could also create a custom merge field provider and maybe a macro to try to "get around" the problem if this is urgent.

    https://www.newsletterstudio.org/documentation/package/12.1.0/develop/merge-field-providers/

    I will set aside some time to look closer at this as soon as possible and please feel free to ask if you need any further assistance on a temporary workaround.

    I'll keep you posted here!

    Cheers!

  • ewuski 88 posts 234 karma points
    Dec 17, 2023 @ 07:43
    ewuski
    0

    Hi, Thanks for quick reply.

    It is not very urgent but it is very good to have. This lets us send personalised links to users otherwise it is difficult to send them relevant information.

    Replying to your question - the url is known, the param is not because the param is custom for each recipient.

    Eg. www.mydomain.com/booking?ref={refNumber}

    In this case {refNumber} must be of course different for each recipient. So it looks like "Field" won't be useful in our case as still we'd need to insert our param somehow for each email.

    I understand we can create a link merge field but in our case it can be any link to any page really depending on the campaign so we'd have to create a case for every page which is obviously not efficient.

    I'll mark our task as blocked and will be awaiting the update to NS.

  • Markus Johansson 1911 posts 5757 karma points MVP c-trib
    Dec 17, 2023 @ 15:36
    Markus Johansson
    0

    Hi again!

    I have tested this now with different versions of Umbraco and the results are the same.

    First of all, if I only enter the URL as a Link (without picking content) it always works without no issues on any version of Umbraco - like this:

    enter image description here

    The same goes for links to content, here are my steps:

    Step 1: Write content in Rich Text Editor, select text and click on the link button in the toolbar

    enter image description here

    Step 2: Select a content item (About us in this example) and add the query string with a merge field in the "Anchor / querystring"-field like this: ?name={{firstname}}

    enter image description here

    Step 3: Save and then go to preview, hover the link and the placeholder is replaced with the value of the merge field. Note that this is a preview where the "firstname"-merge field is replaced with "Test". Not all merge fields are processed during preview since merge fields are dependent on the recipient and the preview does not have any recipient. During preview we provide a subset of the merge fields with test-values but not all providers and merge fields will be provided. To get a realistic result one would have to send the email to a test-recipient.

    enter image description here

    Did you try to send a real email or did you only test with a preview? Please try the steps above and let me know if this works for you. Also please let me know the exact version of Umbraco and Newsletter Studio that you are running.

    A sidenote I've noticed that the Rich Text Editor in all current versions of Umbraco has problems with editing content-links (not the full URLs) that have a query string that contains a merge field like this {{something}}. I'm not sure why but I'm planning to provide an alternative way to write the merge fields (probably [[something]] to get around this issue with the Rich Text Editor. So while this works progresses you need to avoid editing the links if you must pick from the content tree - but your safest option is to paste the full URL as a link like I did in the very first screenshot above.

  • ewuski 88 posts 234 karma points
    Dec 28, 2023 @ 16:43
    ewuski
    0

    We tested a real email. I know the test email only replaces firstName that's fine.

    We are running U10.4.0 and NS10.0.8

    We tried the first suggestion. It works with the exception of linking to the home page where it removes the custom query string only leaving the utm values. Otherwise, other (non-home) links we tested they worked. We'll make further tests anyway so I'll keep you informed if we encounter anything unusual.

    Thank you!

  • Markus Johansson 1911 posts 5757 karma points MVP c-trib
    Dec 28, 2023 @ 14:44
    Markus Johansson
    0

    Hi again!

    I've provided a PR to the Umbraco code that should fix the issue at it's source: https://github.com/umbraco/Umbraco-CMS/pull/15513. I'm hoping that this will be merged in upcoming releases.

    There are a couple of ways to still be able to use merge fields in the URLs on Umbraco-versions where the PR is not included:

    Use absolut URLs and avoid using the "Content Picker"

    This way the issue in the link-parser does not effect the link at all.

    enter image description here

    Use the content picker but never edit

    This is a little more "on the egde" but one could use the picker and select a content-node, add the query string and save the changes. This will work - however it will not be possible to open the link again, and doing so might add extra text to the links in the RTE so this is a quite risky approach.

    Use macro or merge fields

    It would also be possible to use a macro to generate links and or store the full absolute link as a merge field and then use this in the link picker.

    enter image description here

    I hope that some of these work arounds will work for you.

    Cheers!

  • ewuski 88 posts 234 karma points
    Jan 04, 2024 @ 14:38
    ewuski
    0

    Brilliant! Thank you

Please Sign in or register to post replies

Write your reply to:

Draft