13

I am trying to have a link in my email template that would sort of look like this:

<a href={{url}}>click here</>

The above link has been added in de "designer" by adding a "custom" link. The value for this like I enterd as {{url}}.

I pass an url value in the dynamic_template_data, like so:

const msg = {
  to: savedAdmin.email,
  from: process.env.EMAIL_ADDRESS,
  templateId: process.env.SENDGRID_NEW_ADMIN_TEMPLATE_ID,
  personalizations: [
    {
      to: [{email: savedAdmin.email}],
      dynamic_template_data: {
        name: savedAdmin.first_name,
        url: process.env.CMS_URL,
        email: savedAdmin.email,
        password: randomPassword,
      },
    },
  ],
};

However, the url gets rendered like this when I receive the mail in my inbox:

http://url9905.myweb.shop/ls/click?upn=BMmHdsRoNrbb0-2FMI-2BBVvCjpDiCceHLG5U2u5OCf29QV6iCtfuvZYId1FE95cTz9uyMY31z9fQ7iR-2BPgq-2FkquvxdAPC0oMKiLa3DRglYUSVP-2FRmYbDQ-2BdFGnczXk75K3Ym8rSodsrAy-2BfNDJwqA7RDeemPFjepjRsUdci9CA6Y0-....

How do I get this to work?

xfscrypt
  • 16
  • 5
  • 28
  • 59

2 Answers2

17

Sendgrid is replacing your link with a intermediary redirect for click tracking. This user experienced the same issue. From the Sendgrid dashboard, go to Settings->Tracking and click the edit icon on the right for Click Tracking, and disable the feature.

emporerblk
  • 1,063
  • 5
  • 20
4

looks like the cause of this issue is due to not including the http/s prefix to your link. Please change your dynamic variable from "cms.mywebshop.com" to "http://cms.mywebshop.com" or "https://cms.mywebshop.com". Pretty sure this should resolve your issue. Please let me know.

I was able to test not having the http/s prefix on one of my href's and although the tag did not appear as show as plain text, it did fail to forward. It's possible that the folks from Sendgrid made it so the link is shown as plain text for troubleshooting purposes.

Farnoosh
  • 187
  • 1
  • 8
  • Thanks Farnoosh. Even though emporerblk came with the solution, I will look into this as well! Thanks for supporting – xfscrypt May 16 '20 at 07:44
  • I prefer this answer to the accepted one as you can keep tracking turned on with send grid if you want to and the link then still works after being redirected. – Lyle Bennett Apr 04 '22 at 17:13