sendgridsendgrid-api-v3

Sendgrid: How to add a dynamic link to an email template?


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?


Solution

  • 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.