Reputation: 41
I just set-up a dynamic email with sendgrid and am using the API to fill it out based on my customer data.
I've gotten everything to work except the unsubscribe part.
I have an unsubscribe block at the bottom of my email. In the code editor, the code looks like this:
<div data-role="module-unsubscribe" class="module" role="module" data-type="unsubscribe" style="color:#444444; font-size:12px; line-height:20px; padding:16px 16px 16px 16px; text-align:center;" data-muid="67cd14f7-ddbf-421a-a070-57b3b3e6ccac"><p style="font-size:12px; line-height:20px;"><a class="Unsubscribe--unsubscribeLink" href="{{unsubscribe}}" target="_blank" style="">Unsubscribe</a></p></div></td>
I didn't edit the code, that's just how it came. But when I send the email (test or otherwise), the unsubscribe is not a link. Do I need to pass something for {{unsubscribe}} in the API request? If so, what would I pass?
Thanks for your help!
Upvotes: 3
Views: 2737
Reputation: 73027
When you send an email with unsubscribe links, you need to include the unsubscribe group in the API request.
For example:
client
.send({
to: "[email protected]",
from: "[email protected]",
templateId: "YOUR_TEMPLATE_ID",
dynamicTemplateData: { ... },
asm: {
groupId: "YOUR_UNSUBSCRIBE_GROUP_ID"
}
})
Make sure the asm
key is in the root object, not in personalizations
.
Upvotes: 2
Reputation: 1
<div data-role="module-unsubscribe" class="module" role="module" data-type="unsubscribe" style="color:#444444; font-size:12px; line-height:20px; padding:16px 16px 16px 16px; text-align:center;" data-muid="67cd14f7-ddbf-421a-a070-57b3b3e6ccac"><p style="font-size:12px; line-height:20px;"><a class="Unsubscribe--unsubscribeLink" href="{{unsubscribe}}" target="_blank" style="">Unsubscribe</a></p></div></td>
Upvotes: -1