How to Connect Snowflake to Facebook Ads? | 2 Easy Methods

• June 21st, 2022

Snowflake to Facebook Ads- Featured Image

Snowflake is a structured and semi-structured Data Warehouse and Relational Database Management System. It is available through the Software-as-a-Service (SaaS) paradigm and employs a SQL database engine to govern how information is saved in the Database. It runs queries to virtual Warehouses inside the overall Warehouse, each in its cluster node independent of the others, and does not share computational resources.

Facebook Ads are advertisements generated and published on the Facebook network to target its users. This platform provides a rapid, cost-effective, and efficient approach to contacting people with promotional messaging. The advertising may be highly targeted, and you can even design campaigns aimed at a particular target group using the information Facebook collects about its users.

A study from the University of Rhode Island has observed social media as the most successful digital advertising platform for increasing impressions, clicks, and conversions. Facebook, in particular, comes out as being 7x cheaper than the other social media marketing channel.

This article will give you an overview of Snowflake and Facebook Ads before delving into the two methods to connect Snowflake to Facebook Ads. Read along to understand better the step-by-step procedure to connect Snowflake to Facebook Ads.

Table of Contents

What is Snowflake?

Snowflake Logo: Snowflake to Facebook Ads | Hevo Data
Image Source: Wikipedia

Snowflake is a cloud-based Data Warehouse that offers enterprises a scalable and flexible storage system. It is ideal for storing data that can be searched and retrieved later by a Business Intelligence Systems. Despite being hosted in the cloud, it integrates nicely with cloud and on-premise BI solutions.

Snowflake has a subscription-based technique to obtain storage and compute resources separately. It also offers elastic storage, which employs both hot and cold storage techniques to save costs, and scalable compute, which avoids the typical concurrent constraints of conventional Data Warehousing solutions.

Snowflake’s unique design integrates computing and storage natively. This design allows your users and data workloads to access a single copy of your data while retaining speed. Snowflake enables you to distribute your data solution over several locations and clouds while keeping a consistent user experience. Snowflake does this by abstracting the underlying intricacies of cloud infrastructures.

Snowflake Architecture: Snowflake to Facebook Ads | Hevo Data
Image Source: Snowflake

Key Features of Snowflake

Here are the key features of Snowflake:

  • Scalability: Snowflakes’ multi-cluster shared data architecture separates the compute and storage resources. This method allows consumers to scale up resources when large quantities of data need to be loaded quickly and scale back down after the operation is complete without disrupting service. Customers can begin with a small virtual Warehouse and scale up or down as needed.
  • Robust Security: Snowflake contains several security measures. You may set network policies by safely listing IP addresses to restrict access to your account. Snowflake supports several authentication methods, including two-factor and federated authentication for SSO. All data is automatically secured using AES 256 strong encryption, both in transit and at rest.
  • Better Analytics: Snowflake helps you improve your Analytics Pipeline by moving from nightly batch loads to real-time data streams. Allowing secure, concurrent, and controlled access to your Data Warehouse throughout your organization can help you improve your firm’s Analytics quality. This enables businesses to optimize resource allocation to increase revenue while minimizing expenditures and human labor.
  • Improved User Experience: Snowflake provides in-depth insights into user behavior and product usage. Data may also be utilized to improve customer happiness, extend product offerings, and foster data science innovation.
  • Semi-Structured Data Support: Snowflake’s architecture supports storing structured and semi-structured data in the same area using the VARIANT schema on the Read data type. VARIANT can store both structured and semi-structured data.

Seamlessly Replicate Snowflake Data to Business Applications Using Hevo Activate

With Hevo Activate, you can empower business teams with 360° customer profiling — sync customer and product usage data available in Data Warehouses, such as Snowflake, Amazon Redshift, and BigQuery, to most common Business Applications like Salesforce, Google Sheets, HubSpot, and Intercom, etc., in a hassle-free & effortless manner.


Business Teams can now make faster and smarter decisions with Hevo Activate by analyzing user journeys and creating personalized experiences for the customers.

Try our 14-day full access free trial today to experience an automated hassle-free Data Replication!

What are Facebook Ads?

Facebook Ads Logo: Snowflake to Facebook Ads | Hevo Data
Image Source: The Sargent

Facebook Ads is a native advertising (paid media) platform that Facebook offers and develops. It is a self-service advertising service available across all of Facebook’s properties. The advertisements platform is intended to allow anybody to advertise to anyone on Facebook, Instagram, and the Audience Network. It helps businesses of all sizes to promote their products and services effectively. They can reach people on a massive scale, with the capacity to reach over 1.8 billion individuals.

When you use the Facebook ads platform, you are contacting actual people since individuals are the most accurate representations of themselves on the internet. Marketers profit greatly from being able to accurately advertise to actual individuals. These genuine individuals may be accessed through desktop and mobile, as well as at each point of the purchasing experience.

Marketers may approach individuals at any time with a brand awareness message, a purchase consideration message, or a direct conversion message.

Why are Facebook Ads Important?

Here are the reasons why Facebook Ads are important:

  • Facebook is the most widely used social media network, with more than 2.4 billion users and over 7 million advertisers.
  • People spend an average of 35 minutes each day on Facebook.
  • The cost of advertising on Facebook is less than on other social media platforms.
  • It enables you to target your ads based on any demographic, including gender, age, location, career field, etc.
Facebook Advertising Structure: Snowflake to Facebook Ads | Hevo Data
Image Source: Digital Engine Land

Key Features of Facebook Ads

Here are some of the key features of Facebook Ads:

  • Wide Reach of Facebook Platform: With over 2.4 billion active users globally, Facebook is virtually unavoidable when it comes to social media marketing channels. Everyone from teenagers to seniors is using Facebook. With the help of Facebook Ads, your businesses may build company pages and even host events to reach a wide range of audiences.
  • Creative Hub: Facebook’s Creative Hub is an ad mockup tool that allows users to test various ad kinds, locations, and ad components.
  • Facebook Analytics: Facebook Analytics makes it easy for marketers to track the success of their marketing campaigns and gives extra information.
  • Pixel Helper: Pixel Helper is a Chrome Extension that allows users to double-check their implementation, debug their pixel, and learn how to optimize performance with Facebook Ads.

What are the Benefits of Using Snowflake and Facebook Ads?

Marketing is critical for running a successful business – whether it is reaching out to various audiences, raising awareness about the brand, or any other business activity. Organizations store their business, operational, and customer data in a Data Warehouse, such as Snowflake. Loading data from Snowflake to Facebook Ads allows marketers to import Ads, marketing data, and customer insights about consumer behavior and preferences into Facebook Ads. 

Below are the various benefits of loading data from Snowflake to Facebook Ads:

  • Trigger Effective Campaigns: With Snowflake Facebook Ads integration, marketing teams can get immediate access to the frequency of client purchases. Thus, they can set up email, SMS, mobile, and customization campaigns in response to these user activities.
  • Easily Update User Traits: Snowflake Facebook Ads connector may provide your marketing teams with extensive segmentation options by updating user attributes in real time. For example, if most of your customers are on Facebook, marketing teams may leverage the customer data in your Snowflake Warehouse to generate detailed segmentation for Facebook Ads.
  • Optimize Your ROI: Using Snowflake Facebook Ads Connector, your marketing teams can stop wasting time and start focusing on visitors that genuinely matter. They can concentrate their efforts on the channels that convert the best to yield a better return on investment.
  • Reach New Audience: With Snowflake Facebook Ads integration you can continually import audience data from Snowflake to Facebook Ads to reach new audiences and grow your business.

Methods to Connect Snowflake to Facebook Ads

Now that you have a better understanding of Snowflake and Facebook Ads, this section will teach you two methods to connect Snowflake to Facebook Ads.

Method 1: Export Data From Snowflake to Facebook Ads Using CSV

In this Snowflake to Facebook Ads method, you will use your Snowflake Warehouse to get CSV or TXT files containing your target audience’s data and send them to Facebook Ads.

  • Start by creating a Facebook audience to sync your data sources into the Facebook Ads Manager if you don’t already have one.
  • Click on Create Audience, followed by a click on Custom Audience.
  • Select Customer list as a source and click on Next.
  • A pop-up screen will appear, asking you to select whether your data contains required customer values.
  • Then you will be asked to upload the CSV or TXT file. 
  • You need to write a query in Snowflake Web UI to extract the relevant data from Snowflake.
SELECT customer_email AS "cemail"
FROM "customers_america"."XCAT-22030B"."CUSTOMER"
WHERE customer_email IS NOT NULL;
  • Once your query is complete, download the resultant CSV file and review it for any Data Quality concerns, such as missing rows, incorrect email addresses, or anything else that might cause your Data Pipeline to get clogged. 
  • Return to Facebook Ads and upload the file if everything is in order.

Facebook will prompt you to map the columns to their respective IDs, so double-check that your CSV file’s columns have been translated to the right identification format before pressing the import button.

Within minutes, you’ll be able to use this audience for ad targeting – assuming, of course, that Facebook was able to match your data to its users.

Method 2: Sync Data From Snowflake to Facebook Ads with Facebook’s Python API

Step 1: Installing Snowflake to Facebook Ads Python Connector

  • You need to install the Snowflake to Facebook Ads Python Connector. Here’s the command to do so.
pip3 install snowflake-connector-python

Step 2: Connecting to Snowflake

  • Once the Python connector is installed, you must import the hashlib library and create a connection to Snowflake.
import hashlib
import snowflake.connector

conn = snowflake.connector.connect(
    user = "your-username",
    password = "your-password",
    account = "your-account"

Step 3: Querying Snowflake Tables

  • Now, you need to query your data. Let’s say you want to see a list of email addresses, then write the following query.
cursor = conn.cursor().execute("""
    SELECT customer_email AS "cemail"
    FROM "customers_america"."XCAT-22030B"."CUSTOMER"
    WHERE customer_email IS NOT NULL;
  • The data is stored in the cursor as a list of tuples, which may be retrieved using fetchall. The fetchall command matches the Facebook format’s requirements and essentially builds a list of lists. Facebook also requires that we normalize and hash email addresses, as seen in the code below:
data = [[i[0]] for i in cursor.fetchall()]
for i in data:
    i[0] = i[0].lower().strip()
    i[0] = hashlib.sha256(i[0].encode('utf-8')).hexdigest()
  • You need to disconnect from Snowflake once you’ve recovered your data and confirmed that you received what you needed.

Step 4: Setting Up Snowflake Facebook Python Business SDK

Now, you need to utilize Facebook’s Python Business SDK.

  • You must create a Facebook Developer Account in the Facebook App and an Access Token.
  • Afterward, go to your app and select “Add product” in the sidebar to add the Marketing API.
  • Once the Marketing API is displayed in the sidebar, you can click on it to proceed with the setup by selecting Quickstart and clicking on Build Custom Audiences.
  • Write the code mentioned below to install SDK.
pip3 install facebook_business

Step 5: Snowflake Facebook Ads Integration By Importing Snowflake Tables

  • Once you have installed SDK, you need to configure your imports.
from facebook_business.adobjects.adaccount import AdAccount
from facebook_business.adobjects.customaudience import CustomAudience
from facebook_business.api import FacebookAdsApi
  • After you’ve installed the SDK and configured your imports, you’ll need to set up a few settings using the code listed below:
access_token = 'access-token'
app_secret = 'app-secret'
ad_account_id = 'ad-account-id'
audience_name = 'Census demo'
audience_retention_days = '30'
pixel_id = 'pixel-id'
app_id = 'app-id'
  • Next, you can create a connection to the API. If you encounter accessibility issues due to an expired access token, you may utilize Graph API Explorer to generate a new one.
  • You should perform an initial check to ensure that the audiences already exist and determine if you need to add your data to an existing audience or establish a new one entirely.
fields = [

  • If you didn’t find an existing audience and need to establish one, you can do so with the code below.
params = {
  'name': audience_name,
  'subtype': 'CUSTOM',
  'description': 'Snowflake import',
  'customer_file_source': 'USER_PROVIDED_ONLY'

response = AdAccount(ad_account_id).create_custom_audience(params=params)
  • Storing the response provides you access to the ID of the newly generated audience.
params = {
  'payload': {
    'schema': ['EMAIL'],
    'data': data # The list of lists containing hashed email addresses


All these steps will connect Snowflake to Facebook Ads, and your data starts replicating from Snowflake to Facebook Ads.

Limitations of Exporting Data From Snowflake to Facebook Ads Using CSV

Data Migration from Snowflake to Facebook Ads through CSV export is time-consuming. Manually transferring data from Snowflake to Facebook Ads has the following disadvantages:

  • You have to manually inspect the CSV for any Data Quality issues, such as incorrect data, missing rows, or anything else that might block your Data Pipeline.
  • You have to map the columns to their identifiers and ensure that the columns in your CSV file have been translated to the right identification.

Automated Data Replication From Snowflake to Your Business Apps Using Hevo Activate

Reverse ETL Banner: Snowflake to Facebook Ads | Hevo Data

Hevo Activate, a Reverse-ETL platform, automates the manual data enrichment job, directly syncing data from your Snowflake Warehouse to a destination of your choice in real-time. It helps you unify customer & product data from Data Warehouses such as Snowflake, Amazon Redshift, and BigQuery to SaaS Software such as Salesforce, Google Sheets, and other Business Applications like CRM or Customer Support Apps, in a hassle-free & automated manner.

What Makes Hevo Activate Amazing?

Here’s how Hevo Activate is different:

  • Real-Time Data Replication: Hevo Activate, with its strong integration with various data sources, allows you to transfer data quickly & efficiently. This ensures efficient utilization of bandwidth on both ends.
  • No APIs, CSVs, Just SQL!: Use the powerful and smart SQL Query Editor to filter and transform data from your data warehouse table to a Target object. The in-built validation checks ensure each query is validated before you save it.
  • Secure: Hevo Activate has a fault-tolerant architecture that ensures that the data is handled safely and consistently with zero data loss.
  • On-Demand Sync: Hevo Activate gives users the option to resume the sync or run sync now to execute data sync as per their demand.
  • Intelligent Data Type Conversion: During the mapping action, Hevo Activate transforms the field types of the synced data automatically. 
  • Data Transformation: Hevo Activate provides a simple interface to perfect, modify, and enrich the data you want to transfer. 
  • Live Support: The Hevo Activate team is available round the clock to extend exceptional support to its customers through chat, email, and support calls.

Get Customer-Centric with Hevo Activate today!

Sign up here for a 14-day free trial!


This blog introduces Snowflake & Facebook Ads and describes their critical features. It also shows you the two methods for migrating data from Snowflake to Facebook Ads. Snowflake Facebook Ads integration using CSV is a tedious task. It requires a lot of expertise since you must do most of the functions manually, like verifying data, mapping data, etc.

Replicating your customer data from the Snowflake warehouse to your CRM apps or BI tools, and so on might be difficult, and which is where Hevo Activate comes in.

Hevo Activate will automate your data transfer process, allowing you to focus on other aspects of your business, such as analytics and customer management. This platform transfers data from Cloud-based Data Warehouses such as Snowflake, Google BigQuery, Amazon Redshift, and others to CRMs such as Salesforce and Business Intelligence Software. It will make your job easier and provide you with a stress-free experience.


Want to take Hevo Activate for a ride? SIGN UP for a free 14-day trial to streamline your data integration process. You can check out the pricing options to determine which plan best meets the demands of your business.

You can share your learning experience about creating a Snowflake Facebook ads connector in the comments below.

Sync Data from Snowflake to Business Applications Seamlessly