2

I am using unsubscribe group to send email using dynamic template but the link isnt clickable

 dynamic_template_data = {
     
                    "asmGroupUnsubscribeUrl": "<%asm_group_unsubscribe_url%>",

                }

I have used the dynamic template data in html , have created a unsubscribe group and sent group id like this:

 data = {"personalizations": [{
        "to": [
            {
                "email": email
            }
        ],

        "dynamic_template_data": dynamic_template_data,
        "asm": {
            "group_id":111,
            "groups_to_display": [111],
        },

    }....

IS there anything i should add or doing something wrong? I am using it in html as: Tried many things but nothing worked

   <a  href="{{asmGroupUnsubscribeUrl}}">Unsubscribe</a>
Luff li
  • 123
  • 2
  • 11
  • What syntax/language is `"<%asm_group_unsubscribe_url%>"` being done in? If it's some sort of embedded language (erb, ejs, epy) then there normally needs to be an `=` to print out the data, like `"<%= asm_group_unsubscribe_url%>"`. – philnash Sep 22 '21 at 03:36
  • I used https://docs.sendgrid.com/ui/sending-email/group-unsubscribes and just added <%asm_group_unsubscribe_url%> in my href. – Luff li Sep 22 '21 at 04:28
  • Ah, I see. I'm not sure that would get parsed when it is entered as template variables. Why not add `<%asm_group_unsubscribe_url%>` directly to your template, like `Unsubscribe` instead? – philnash Sep 22 '21 at 06:22
  • 2
    Found the issue! "asm": was supposed to be kept outside "personalizations" array. – Luff li Sep 22 '21 at 06:34
  • Oh, good news! Well spotted. – philnash Sep 22 '21 at 06:35

0 Answers0