Documentation / Product / Integrations / SendGrid

SendGrid: Import Users & Activity

Importing user and activity data from SendGrid results in new users and/or existing user profiles supplemented with SendGrid campaign activity data. You can use this data to build and refine your existing Lytics audiences to power better, cross-channel campaigns.

Integration Details

  • Implementation Type: Server-side.
  • Implementation Technique: REST API, Webhooks.
  • Frequency: User data is batch imported daily, on a continuous basis. Activity data, if configured, is received in real-time.
  • Resulting Data: Full user profiles for all SendGrid contacts or users in the selected lists. If configured, activity data related to marketing campaigns and transactional emails at the event level will be collected as additional user fields.

This integration utilizes the SendGrid APIs to receive user data. On each run of the workflow, it will:

  1. Query for all contacts in your SendGrid account, or if you've configured Import Lists, it will query for recipients of those lists.
  2. For each contact that has been updated since the last run of the workflow (or for all users on the first run of the workflow) it will:
    1. Query for list membership of that user.
    2. Ingest the collected user data into the sendgrid_users stream.

If the Import email events option is selected during the configuration process, on the first run of the workflow it will also:

  1. Check if webhooks are set up in the SendGrid account.
  2. Automatically apply the proper settings to your SendGrid account to enable activity data to be sent to Lytics.
  3. After this, user activity is received in Lytics via webhook, reformatted on ingestion, and available in the sendgrid_activity stream.

Note: If you've already configured webhooks to send to another destination in your account, this workflow will not overwrite your existing settings. You can manually set up SendGrid webhooks to go to Lytics by following these instructions.

Fields

The following fields are included in the default mapping of the sendgrid_users stream:

Source FieldLytics User FieldDescriptionType
emailemail unique idEmailstring
emailemaildomainEmail Domainstring
first_namefirst_nameFirst Namestring
idsendgrid_id unique idSendGrid User IDstring
last_clickedsg_last_clickedLast Clickeddate
last_emailedsg_last_emailedLast Emaileddate
last_namelast_nameLast Namestring
last_openedsg_last_openedLast Openeddate
list_idssg_list_idsSendGrid List IDs[]string
list_namessg_list_namesSendGrid Lists[]string

Lytics will import any and all custom fields from SendGrid, however this stream does not automatically map these fields. If you would like to map the imported custom fields to Lytics user fields, contact customer support for assistance.

The following fields are included in the default mapping of the sendgrid_activity stream:

Source FieldLytics User FieldDescriptionType
eventemail_open_ct
email_sent_ct
email_click_ct
email_complaint_ct
email_bounce_ct
sg_email_opens
sg_email_action
Email Opened
Email Send
Email Clicked
Email Complaint
Email Bounced
SendGrid Email Opens
SendGrid Email Actions
int
int
int
int
int
int
map[string]int
timestamplast_active_ts
email_lastopen_ts
email_firstopen_ts
email_last_sent_ts
email_first_sent_ts
email_lastclick_ts
email_firstclick_ts
email_last_complaint_ts
email_first_complaint_ts
email_last_bounce_ts
email_first_bounce_ts
Last Active
Last Email Opened
First Email Opened
Last Email Sent
First Email Clicked
First Email Sent
Last Email Clicked
Last Email Complaint
First Email Complaint
Last Email Bounced
First Email Bounced
date
date
date
date
date
date
date
date
date
date
date
bounce_typesg_bounce_typeSendGrid Bounce Type[]string
reasonsg_error_reasonstring
categoryemail_categoryEmail Categoriesmap[string]int
urlemail_urls
hashedurls
Email Urls Clicked on
Hashed Urls Visited
[]string
map[string]int
marketing_campaign_namesg_campaignsSendGrid Campaignsset
"email"channels
last_channel_activities
Channels
Last Activity By Channel
[]string
map[string]date
emailemail unique id
emaildomain
Email
Email Domain
string
string
experience_idsg_impressions
sg_conversions
Reached with SendGrid Experience
Converted on SendGrid Experience
map[string]int
map[string]int

Configuration

Follow these steps to set up and configure an import of SendGrid users in the Lytics platform.

  1. Navigate to the Integrations page and select the SendGrid tile. SendGrid Tile
  2. Select Workflows from the menu on the left.
  3. Select Import Users from the list of workflows.
  4. Select the authorization you would like to use.
  5. (Optional) Select the Import email events checkbox if you want to import activity data via webhooks. As noted above, this will only turn on webhooks if they are not already configured to another destination within your SendGrid account. You can also manually set up SendGrid webhooks to go to Lytics by following these instructions.
  6. (Optional) Under Advanced Options you may select a limited number of lists to import using the Import Lists selection. If not selected, the import will default to collect data on all contacts. Screenshot from 2019-05-23 19-51-35

Once configured, click Start Import to begin the import workflow.