SendGrid与Keen IO集成:能否将SendGrid事务模板ID同步至Keen IO?
Great question! The short answer is yes, you can send SendGrid Transactional Template IDs to Keen IO—but it doesn’t happen automatically with the default integration. You’ll need to explicitly add a custom field to pass this data along. Here’s how to set it up:
Step 1: Add the Template ID as a Custom Argument in SendGrid
By default, SendGrid’s event webhook doesn’t include the Transactional Template ID in the data it sends to Keen IO. You’ll need to manually include it via custom_args when sending your emails:
If using the SendGrid API:
When building your email payload, add the template ID to thecustom_argsobject like this:{ "personalizations": [ { "to": [{"email": "recipient@example.com"}], "custom_args": { "sendgrid_template_id": "d-1234567890abcdef12345678" } } ], "template_id": "d-1234567890abcdef12345678", "from": {"email": "sender@example.com"} }If using SMTP:
Include the template ID in theX-SMTPAPIheader of your email. The header value would look like:{"custom_args": {"sendgrid_template_id": "d-1234567890abcdef12345678"}}
Step 2: Ensure Keen IO Captures the Custom Field
Once SendGrid is sending the custom template ID, Keen IO’s default SendGrid integration will usually parse and store fields from custom_args as top-level properties in your events automatically.
If you don’t see the field right away:
- Double-check that your SendGrid webhook is correctly pointing to your Keen IO project’s event collection endpoint.
- If you’ve set up strict schema rules in Keen, confirm that
sendgrid_template_idis included in the allowed properties for your data stream.
Step 3: Verify and Start Filtering
Send a test email using your Transactional Template, then check Keen IO’s event explorer. You should now see the sendgrid_template_id field in your event data. From there, you can use this field to filter events, build analytics reports, or segment your email performance data by template.
A quick side note: If you’re using SendGrid Marketing Campaigns templates instead of Transactional Templates, the process is identical—just plug in the relevant template ID into your custom_args.
内容的提问来源于stack exchange,提问作者Richard Butterwood

