Snowflake Secure Data Sharing – Cordial Knowledge Base

How can we help?

Overview

With Snowflake’s Secure Data Sharing integration, you can gain instant access to valuable first-party user data generated from Cordial—directly in your designated Snowflake account. Cordial’s Snowflake portal gives you seamless, secure, and real-time access to your customer’s activity, orders, custom events, and profile data in an easy and frictionless way—all without the need for typical extract, transform, and load (ETL) data sharing solutions.

For Cordial customers on the Snowflake Data Cloud, this partnership will enable live access to your valuable first-party customer data, empowering you with the data agility to analyze engagement trends, monitor consumer behaviors, gauge performance, and unlock new insights about metrics driving your business.

Data architecture

Use cases

Prerequisites

You need a Snowflake account for this integration.

What is Data Sharing?

Snowflake’s Secure Data Sharing is a proprietary way to allow businesses, like Cordial, to seamlessly grant and share data with partner client organizations—like you! Unlike traditional data sharing, Snowflake Data Sharing is far easier to use because it provides immediate access to ready-to-query data, eliminating friction and unnecessary cost that come with ETL processes.

How it works

With Secure Data Sharing, no actual data is copied, transferred, or exchanged between accounts, which eliminates data movement. All sharing is accomplished through Snowflake’s unique multi-cluster shared data architecture.

This is an important concept because it means that sharing data from Cordial to your Snowflake account does not take up any storage in your Snowflake consumer account—and therefore does not contribute to your monthly Snowflake data storage cost. The only charges are for the compute resources used to query on shared Cordial data.

Benefits

Request a Secure Share

Visit Cordial's listing in the Snowflake marketplace to request a Secure Share and reach out to your client success manager. You may need to provide your Snowflake account information, which is available by clicking the Copy button in the Account Information dropdown, to help our team verify and provision your request.

Once you've requested a Secure Share, Cordial will verify and provision the data share from our Cordial 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.

  1. Your account administrator will need to log in to your Snowflake account, click on Shares in the top navigation bar, and accept the share request from Cordial.

  2. To accept the share request, select the Secure Share and click Create Database from Secure Share.

  3. Your account administrator can then give the Secure Share a Database Name, select who can access the data, and leave any comments.

  4. You can then go to the Worksheets tab in the top navigation bar in your Snowflake instance and see the new Cordial shared database and shared dataset.

Query the Secure Data 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 live customer data in near real-time.

Data View Name Description
Contact attributes contacts 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 contacts Cart items are stored with each contact and can contain information about a product such as SKU, description image, and much more.
Events contactactivity 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.
Message sends messagesends 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.
Orders orders Data about a contact's order history.

Example queries

The Snowflake data share allows you to build powerful queries to get the exact data you want. Here are two examples.

CONTACTS

Here is an example query that uses the CONTACTS view 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
;
grand_total_amount average_total_amount average_num_cart_items total_carts
41479622 1595370.077 13.961538 26

This query demonstrates Snowflake’s support for querying structured data. In this case, the cart field is an object with several embedded keys such as totalAmount and cartitems (which is itself an array of zero or more nested item objects).

CONTACTACTIVITY

Here is an example query that demonstrates selecting data from the CONTACTACTIVITY view. 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 '2024-09-19' AND '2024-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
action_date message-sent open click bounce
2024-09-19 2749273 1080279 3015 2829
2024-09-20 2605236 1796475 7139 6229
2024-09-21 2738569 1884556 4742 2145
2024-09-22 3073 929171 1485 6047
2024-09-23 2810032 812085 2628 466
2024-09-24 2041732 1600629 4839 2258
2024-09-25 928 87 1 1

Definitions

Message Sends

The statuses below indicate the current lifecycle state of a message send in the messagesends view.

Value Definition
sent Message has been delivered to recipients.
scheduled Configured to send at a future time.
draft Not active yet; still being edited/prepared.
interval Sent dynamically by an automation or trigger event.
recordsQueued Accepted and waiting in the processing queue.