Export Google Ads Attribution Data to Snowflake (Step-by-Step)

17 minutes to read
Get free consultation

 

Marketing teams live and breathe data. You have a wealth of powerful attribution data sitting right inside Google Ads, telling you which campaigns, ads, and keywords are driving conversions. But this data is in a silo. You can uncover true, game-changing insights when you blend this ad data with your CRM, sales figures, and product usage information. The key to unlocking this potential is creating a robust data pipeline from Google Ads into a central data warehouse like Snowflake.

This guide will walk you through the entire process. We’ll explore two primary paths for getting your data where it needs to be: a manual, script-based approach for those who want deep control, and a managed, automated solution for teams that need to focus on analysis, not infrastructure. By the end, you will know how to set up API access, extract critical data, load it into Snowflake, and model it for powerful analysis.

Why Bother Exporting Google Ads Data to Snowflake?

Moving data might seem like a purely technical task, but the business value it unlocks is immense. By creating a direct data highway from Google Ads to Snowflake, you empower your entire organization to make smarter, data-driven decisions. It’s the foundational step toward building a single source of truth for all your marketing efforts.

Break Down Data Silos for a Single Source of Truth

Your Google Ads data is only one piece of the puzzle. When you pipe it into Snowflake, you can join it with customer data from your CRM (like Salesforce), transaction data from your payment processor, and user behavior data from your product analytics tools. This allows you to answer critical business questions like: “What is the true lifetime value of customers acquired through our top-performing ad campaigns?”

Enable Advanced, Custom Attribution Modeling

You can move beyond last-click attribution by getting your data into Snowflake. Google’s built-in attribution models are a great start, but they don’t know your business’s unique sales cycle or customer journey. Once your data is centralized, you can build custom multi-touch, time-decay, or even machine learning-based attribution models that assign credit more accurately across every touchpoint, giving you a far more nuanced understanding of your marketing ROI.

Retain Your Data Indefinitely

Exporting your data to Snowflake means you own it forever. This helps you get around the data retention limits of platforms like Google Ads, where your historical performance data can disappear over time. With your own copy, you can analyze year-over-year trends, track long-term customer behavior, and build predictive models without worrying about data expiring from the source platform.

Enhance Business Intelligence and Reporting

Snowflake serves as the perfect foundation for your Business Intelligence (BI) stack. You can connect tools like Looker or Tableau directly to your centralized data warehouse. This enables your team to build powerful, unified dashboards that visualize the entire customer journey, from the first ad click to the final sale and beyond, all updated in near real-time.

Method 1: The Manual Approach Using the Google Ads API and Scripts

For teams with engineering resources, the DIY approach offers maximum flexibility and control. This method involves connecting directly to the Google Ads API, writing a script to extract the data you need, and loading it into Snowflake. This powerful approach gives you full control, but it’s important to plan for ongoing maintenance.

Step 1: Setting Up Google Ads API Access

Before you can pull any data, you need to get the right credentials. This is a crucial first step that authenticates your requests.

Prerequisites:

Process:

  1. Enable the API: In your Google Cloud Platform (GCP) console, create a new project and enable the Google Ads API for it.
  2. Configure OAuth 2.0: Set up an OAuth 2.0 consent screen and create credentials (a client ID and client secret). This is how your script will securely authenticate on behalf of your Google account.
  3. Get a Refresh Token: You’ll use your client ID and secret to run an authentication flow that generates a refresh token. This token allows your script to get new access tokens without requiring manual re-authentication each time.

 

For a detailed walkthrough, always refer to the official Google Ads API documentation.

Callout: Google Ads API vs. Google Ads Scripts While both can be used for reporting, they serve different purposes. Google Ads Scripts run directly within the Google Ads UI and are great for simple account automation and basic reporting. The Google Ads API is a far more powerful and scalable interface designed for pulling large, complex datasets, making it the right choice for building a data pipeline into a warehouse like Snowflake.

Step 2: Extracting Attribution Data via API

With your credentials ready, you can start querying the API. The best way to do this is with the Google Ads Query Language (GAQL), which is similar to SQL. Your goal is to pull reports that contain performance metrics and, most importantly, the identifiers needed to link ad interactions to conversions.

A key identifier is the gclid (Google Click ID), which is appended to your URLs when a user clicks an ad. Capturing this is essential for attribution.

Here is a sample GAQL query to pull campaign performance data along with click-level details.

SELECT
  campaign.id,
  campaign.name,
  ad_group.id,
  ad_group.name,
  metrics.clicks,
  metrics.impressions,
  metrics.cost_micros,
  metrics.conversions,
  click_view.gclid,
  segments.date
FROM click_view
WHERE segments.date BETWEEN 'YYYY-MM-DD' AND 'YYYY-MM-DD'

This query extracts campaign and ad group details, performance metrics, the date of the interaction, and the gclid. You would run this query via your script (e.g., in Python using the Google Ads client library) and export the results into a structured format like a CSV file.

Step 3: Preparing Snowflake and Loading the Data

Now, let’s switch over to Snowflake. First, you need a table to hold your Google Ads data. It’s a best practice to design a schema that matches the data you are extracting.

Here is a sample DDL command to create a landing table for our campaign performance data.

CREATE OR REPLACE TABLE google_ads_campaign_performance (
    report_date DATE,
    campaign_id STRING,
    campaign_name STRING,
    ad_group_id STRING,
    ad_group_name STRING,
    gclid STRING,
    clicks INT,
    impressions INT,
    cost_micros INT,
    conversions FLOAT
);

With the table created, you need to get your CSV file into a location Snowflake can access. This is called a “stage.” You can use an internal Snowflake stage or an external one (like an S3 bucket).

Once your file is staged, you can use a single command to load the data directly into your table. The Snowflake’s COPY INTO command is highly optimized for this kind of bulk loading.

COPY INTO google_ads_campaign_performance
FROM @your_internal_stage/campaign_data.csv
FILE_FORMAT = (TYPE = 'CSV' SKIP_HEADER = 1 FIELD_OPTIONALLY_ENCLOSED_BY = '"');

This manual process gives you a complete pipeline. With this manual pipeline in place, you’ll be responsible for scheduling the script, handling API errors, managing authentication token refreshes, and keeping the code updated with any Google API changes.

Method 2: The Automated Approach with a Managed Data Pipeline

To build a scalable and robust solution, most teams turn to automated pipelines. The manual approach can be fragile and difficult to scale. A managed ELT (Extract, Load, Transform) service becomes invaluable, allowing your team to focus on generating insights, not managing infrastructure.

How Managed ELT Services Work

Managed data pipeline services use pre-built connectors to handle the entire data integration process. These connectors are purpose-built to:

The Stellans Advantage: A White-Glove Marketing Data Pipeline

At Stellans, we take this a step further. Our fully managed service goes beyond just moving your data; we guarantee it’s ready for analysis from day one. We believe that a data pipeline is not just a technical utility; it’s a strategic asset.

Our approach is to act as your empowering partner. We work with you to understand your business goals and build a robust data foundation to support them. With the Stellans Marketing Data Pipeline service, you get more than just a connector. You get:

Bringing It All Together: Example Attribution Queries in Snowflake

Once your Google Ads data is flowing into Snowflake, the real fun begins. You can now write powerful SQL queries to analyze performance in ways that are impossible within the Google Ads UI alone.

Sample Schema for Marketing Attribution

A good starting point involves having separate tables for ad performance and conversion events, which can be joined using a common identifier.

google_ads_performance      crm_conversions
report_date (DATE) conversion_timestamp (TS)
campaign_id (STRING) customer_id (STRING)
ad_group_id (STRING) revenue (DECIMAL)
gclid (STRING) gclid (STRING)
clicks (INT) conversion_action (STRING)
cost_micros (INT)

 

Sample SQL Query: Campaign Performance by Conversion Action

This query helps you understand which campaigns are driving specific types of valuable conversions, assuming you have joined your ad data with CRM data on the gclid.

-- Calculate revenue and count of conversions per campaign and conversion type
SELECT
    p.campaign_name,
    c.conversion_action,
    COUNT(c.customer_id) AS total_conversions,
    SUM(c.revenue) AS total_revenue
FROM
    google_ads_performance p
JOIN
    crm_conversions c ON p.gclid = c.gclid
GROUP BY
    1, 2
ORDER BY
    total_revenue DESC;

Sample SQL Query: Basic Last-Click Attribution by Day

This query provides a daily summary of ad spend, conversions, and cost per acquisition (CPA), attributing each conversion to the last ad click.

-- Summarize daily performance with last-click attribution
WITH daily_costs AS (
    SELECT
        report_date,
        campaign_name,
        SUM(cost_micros / 1000000) AS daily_spend -- Convert from micros to base currency
    FROM
        google_ads_performance
    GROUP BY 1, 2
),
daily_conversions AS (
    SELECT
        DATE(c.conversion_timestamp) AS conversion_date,
        p.campaign_name,
        COUNT(c.customer_id) AS conversions
    FROM
        crm_conversions c
    LEFT JOIN
        google_ads_performance p ON c.gclid = p.gclid
    GROUP BY 1, 2
)
SELECT
    dc.report_date,
    dc.campaign_name,
    dc.daily_spend,
    dv.conversions,
    (dc.daily_spend / NULLIF(dv.conversions, 0)) AS cost_per_acquisition
FROM
    daily_costs dc
JOIN
    daily_conversions dv ON dc.report_date = dv.conversion_date AND dc.campaign_name = dv.campaign_name
ORDER BY
    dc.report_date DESC;

Common Pitfalls and How to Avoid Them

Building a data pipeline is not without its challenges. Here are a few common issues and how to mitigate them.

Conclusion: Your Data, Centralized and Ready for Analysis

Exporting your Google Ads attribution data to Snowflake is no longer a luxury; it’s an essential step toward building a sophisticated marketing analytics engine. It breaks down data silos, enables true cross-channel analysis, and empowers you to make decisions with confidence.

The manual path offers ultimate control, but it’s important to consider the significant and ongoing investment of engineering resources it requires. Alternatively, you can opt for an automated solution that delivers reliable, analysis-ready data without the maintenance overhead. This allows your team to do what they do best: uncovering the insights that drive business growth.

If you’re ready to move beyond managing fragile data scripts, let us build you a rock-solid marketing data pipeline. Schedule a free consultation with a Stellans data expert today.

Frequently Asked Questions

How do I automate sending Google Ads data to Snowflake?

You can automate the process by using a dedicated ETL/ELT service with a pre-built Google Ads to Snowflake connector. These tools handle API authentication, data extraction, transformation, and loading on a recurring schedule, eliminating manual work and ensuring data freshness.

What is the best way to maintain attribution detail when moving ad data to a warehouse?

To maintain attribution detail, ensure your data pipeline captures granular identifiers like Google Click ID (gclid), timestamps for every interaction, and all relevant campaign, ad group, and keyword IDs. A well-designed schema in Snowflake is crucial to store and relate these details correctly for analysis.

Can Snowflake handle multi-touch attribution models?

Yes, Snowflake is an excellent platform for building and running custom multi-touch attribution models. Its powerful SQL engine allows you to write complex queries that analyze user paths, assign credit across various touchpoints, and join advertising data with other business data (like CRM or sales records) for a complete view of the customer journey.

Article By:

https://stellans.io/wp-content/uploads/2024/08/image-63346022-1.png
Ilya Novoselskiy

Lead Data Scientist at Stellans

Related Posts

    Get a Free Data Audit

    * You can attach up to 3 files, each up to 3MB, in doc, docx, pdf, ppt, or pptx format.