Easy access to real-time customer data is crucial in marketers' efforts to send messages that resonate. Marketers also need to leverage that data to understand customer behavior and shape strategy. The bidirectional data integration between Cordial and Snowflake unlocks this potential.
Using Cordial, data-driven marketing teams create personalized email, SMS, mobile, and website experiences for enterprise audiences, loading dynamic content tailored to message and site behavior, product affinity, seasonal deals, and more. With its industry leading data storage, Snowflake naturally complements what marketers can do with Cordial's marketing platform.
In this Quickstart, Cordial and Snowflake walk you through how to set up a bidirectional data share between platforms so you can leverage your Snowflake customer data in Cordial and vice versa.
This Quickstart is for data-driven marketers who want to unlock message personalization and segmentation possibilities at scale. You'll set up a Secure Data Share to easily access Cordial data within Snowflake—and then enable Snowflake as a source to import data into Cordial.
At the end of this Quickstart, you will successfully:
Snowflake's Secure Data Share provides Cordial with immediate access to ready-to-query data. To get started, you need to request a Secure Share.
Once you've requested the Secure Share, Cordial will verify and provision the data share from Cordial's Snowflake account to your Snowflake account. After the share is provisioned, Cordial will notify you that your data share has been provisioned—and you'll need to follow the steps below to accept the Secure Share.
Once you accept the Cordial data share and assign it to a new database in your Snowflake account, you can start querying the data share. Here are the datasets available to query.
The following datasets are available from Cordial through a Secure Data Share. Data is refreshed multiple times per day, giving you direct access to customer data in near real-time.
View | Description |
| Data specific to each contact such as name, address, etc. You can store string type (i.e. first name), number type (i.e. age), geo type (i.e. addresses), and array type (i.e. favorite colors). You can add as many attributes as needed to describe your contacts. Cart items are also stored with each contact and can contain information about a product such as SKU, description image, and much more. |
| Data related to a contact's activity or behavior. This can be message activity as well as website activity (browsed a page, added to cart), or external (IoT) activity. |
| Data specific to message sends, such as the channel used to send the message, whether the message is promotional or transactional, information about how and when the message was created, and more. |
| Data about a contact's order history. |
The Snowflake Secure Data Share allows you to build powerful queries to get the exact data you want. Here are two examples.
CONTACTS
Here's an example query that uses CONTACTS
to find (1) the grand total dollar amount of all cart items across all carts, (2) the average dollar amount of all cart items per cart, (3) the average number of items per cart, and finally (4) the total number of carts.
SELECT
SUM(TRY_TO_NUMBER(cart:"totalAmount"::varchar)) as "grand_total_amount",
AVG(TRY_TO_NUMBER(cart:"totalAmount"::varchar)) as "average_total_amount",
AVG(ARRAY_SIZE(cart:"cartitems")) as "average_num_cart_items",
count(*) as "total_carts"
FROM
contacts
WHERE
cart IS NOT NULL
;
|
|
|
|
41479622 | 1595370.077 | 13.961538 | 26 |
CONTACTACTIVITY
Here's an example query that demonstrates selecting data from CONTACTACTIVITY
. The query returns total daily counts for several events (aka actions) related to sending messages for a specified date range (message sends, opens, clicks, and bounces). This query makes use of some advanced SQL features such as Common Table Expressions and the PIVOT
function, demonstrating Snowflake's rich SQL support.
WITH action_totals AS (
SELECT
to_date(action_date) as action_date,
action,
count(*) as total
FROM
contactactivity
WHERE
action_date BETWEEN '2022-09-19' AND '2022-09-25'
AND action IN ('message-sent', 'open', 'click', 'bounce')
GROUP BY
action_date,
action
)
SELECT
*
FROM
action_totals
PIVOT (
SUM(total) FOR action IN ('message-sent', 'open', 'click', 'bounce')
) as p
ORDER BY
action_date
|
|
|
|
|
2022-09-19 | 2749273 | 1080279 | 3015 | 2829 |
2022-09-20 | 2605236 | 1796475 | 7139 | 6229 |
2022-09-21 | 2738569 | 1884556 | 4742 | 2145 |
2022-09-22 | 3073 | 929171 | 1485 | 6047 |
2022-09-23 | 2810032 | 812085 | 2628 | 466 |
2022-09-24 | 2041732 | 1600629 | 4839 | 2258 |
2022-09-25 | 928 | 87 | 1 | 1 |
Cordial provides an array of opportunities to leverage your Snowflake customer data to send messages that resonate. When Snowflake is enabled as a data source in Cordial, Cordial automatically queries one or multiple Tables and/or Views in your Snowflake warehouse on a customizable interval.
The Cordial platform automatically detects and updates any new or updated customer records. This keeps your customer data in sync with Snowflake cloud data for real-time segmentation and message personalization.
In your Snowflake account, create a Table or View to store the customer data you want to utilize in your Cordial account. Here are some important settings to keep in mind when creating your Table in Snowflake:
VARCHAR
columns. Column size limit is 8kb or VARCHAR(8192)
.Geo attributes should be represented as separate columns. For example, the geo attribute homeaddress
would be broken up into columns such as:
homeaddress.street_address
homeaddress.city
homeaddress.state
homeaddress.postal_code
Array attributes will be updated as a whole unless additional syntax is included to add or remove an item from an array, as follows:
{ "remove": ["apple"] }
{ "add": ["apple"] }
Note: Your Table/View must be set to convert nanoseconds (default in Snowflake) into microseconds (default in Cordial) in order to successfully transfer date attributes.
You can enable Snowflake as a data source in Cordial's UI.
Note: Connection parameters are case-sensitive and should match the exact case of the named objects—warehouse, user, role, database, Table/View, or schema—in Snowflake.
Select this method if you want to use key-pair authentication in Snowflake.
Note: Don't include the —–BEGIN PUBLIC KEY—–
and —–END PUBLIC KEY—–
that appear with your PEM key. Snowflake requires these markers to be removed in their environment.
In Cordial, you can use Data Jobs to:
These steps unlock Cordial's powerful automated messaging capabilities.
Note: Cordial will automatically query Snowflake at a specified interval, updating modified records and inserting any new records since the last sync. You can configure your data refresh interval to occur every 15 minutes, every 30 minutes, every hour, every week, or every month to optimize access to real-time data.
One-time Data Jobs only support full refresh syncs. Recurring Data Job Automations support both full refresh and incremental syncs.
WHERE
and ORDER
elements.{prevValue}
Note: If the cursor field has unique values, such as unique IDs, Cordial can simplify the process and select all the new records. But if the cursor field is not unique, such as a timestamp or date, Cordial skips one or more records with the maximum value.
In the examples below, UPDATED_AT
and ORDER_ID
are cursor fields:
SELECT ... WHERE ORDER_ID {prevValue}
SELECT ... WHERE UPDATED_AT {prevValue} AND UPDATED_AT <(select
max(updated_at)="max(UPDATED_AT)" from="FROM" {table})="{table})"></(select>
Note: The second example means Cordial doesn't import at least one row with max(UPDATED_AT)
The following Cordial endpoints support Snowflake as a data source:
Example JSON request:
{
"source":{
"transport":"snowflake",
"connection":"same_name_used_in_marketplace_setup",
"tableview":"same_table_view_name_used_in_marketplace_setup"
},
"hasHeader":true,
"confirmEmail":"msmith@example.com"
}
If you need to stop the sync, you can disable the connection by clicking Configure on the Snowflake card in Cordial (Integrations > Partners) and selecting the Disable button. When the connection is re-enabled, the job will continue looking for all records that were inserted or updated since the last sync.
Congratulations! You have successfully learned how to create a two-way data share between Cordial and Snowflake, unlocking new opportunities for your team.
Want to learn more about Cordial and Snowflake? Check out the following resources: